Java Code Examples for ch.qos.logback.classic.spi.LoggingEvent#setMarker()
The following examples show how to use
ch.qos.logback.classic.spi.LoggingEvent#setMarker() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GelfEncoderTest.java From logback-gelf with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void singleMarker() throws IOException { encoder.setLoggerNameKey("Logger"); encoder.start(); final LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); final Logger logger = lc.getLogger(LOGGER_NAME); final LoggingEvent event = simpleLoggingEvent(logger, null); event.setMarker(MarkerFactory.getMarker("SINGLE")); final String logMsg = encodeToStr(event); final ObjectMapper om = new ObjectMapper(); final JsonNode jsonNode = om.readTree(logMsg); coreValidation(jsonNode); assertEquals("SINGLE", jsonNode.get("_marker").textValue()); }
Example 2
Source File: GelfEncoderTest.java From logback-gelf with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void multipleMarker() throws IOException { encoder.setLoggerNameKey("Logger"); encoder.start(); final LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); final Logger logger = lc.getLogger(LOGGER_NAME); final LoggingEvent event = simpleLoggingEvent(logger, null); final Marker marker = MarkerFactory.getMarker("FIRST"); marker.add(MarkerFactory.getMarker("SECOND")); event.setMarker(marker); final String logMsg = encodeToStr(event); final ObjectMapper om = new ObjectMapper(); final JsonNode jsonNode = om.readTree(logMsg); coreValidation(jsonNode); assertEquals("FIRST, SECOND", jsonNode.get("_marker").textValue()); }
Example 3
Source File: MetricPassFilterTest.java From lambda-monitoring with Apache License 2.0 | 5 votes |
@Test public void testPassesMetricMarker() { LoggingEvent event = new LoggingEvent(); event.setMarker(METRIC_MARKER); MetricPassFilter filter = new MetricPassFilter(); filter.start(); assertEquals(FilterReply.NEUTRAL, filter.decide(event)); }
Example 4
Source File: MetricPassFilterTest.java From lambda-monitoring with Apache License 2.0 | 5 votes |
@Test public void testBlocksNonMetricMarker() { LoggingEvent event = new LoggingEvent(); event.setMarker(MarkerFactory.getMarker("FOO")); MetricPassFilter filter = new MetricPassFilter(); filter.start(); assertEquals(FilterReply.DENY, filter.decide(event)); }
Example 5
Source File: MetricBlockFilterTest.java From lambda-monitoring with Apache License 2.0 | 5 votes |
@Test public void testBlocksMetricMarker() { LoggingEvent event = new LoggingEvent(); event.setMarker(METRIC_MARKER); MetricBlockFilter filter = new MetricBlockFilter(); filter.start(); assertEquals(FilterReply.DENY, filter.decide(event)); }
Example 6
Source File: MetricBlockFilterTest.java From lambda-monitoring with Apache License 2.0 | 5 votes |
@Test public void testPassesNonMetricMarker() { LoggingEvent event = new LoggingEvent(); event.setMarker(MarkerFactory.getMarker("FOO")); MetricBlockFilter filter = new MetricBlockFilter(); filter.start(); assertEquals(FilterReply.NEUTRAL, filter.decide(event)); }
Example 7
Source File: JobMessageLogAppenderTest.java From edison-microservice with Apache License 2.0 | 5 votes |
private LoggingEvent createLoggingEvent(final Level level, final String message, final Object... params) { final LoggingEvent loggingEvent = new LoggingEvent(); loggingEvent.setMDCPropertyMap(singletonMap("job_id", "someJobId")); loggingEvent.setMessage(message); loggingEvent.setArgumentArray(params); loggingEvent.setLevel(level); loggingEvent.setMarker(JobMarker.JOB); return loggingEvent; }
Example 8
Source File: ExcludeClassifiedMarkerFilterTest.java From owasp-security-logging with Apache License 2.0 | 5 votes |
@Test public void testRaw() { // create a new marker filter ExcludeClassifiedMarkerFilter mkt = new ExcludeClassifiedMarkerFilter(); mkt.setContext(loggerContext); mkt.start(); assertTrue(mkt.isStarted()); // test a logging event with no markers ILoggingEvent nulEvent = new LoggingEvent(); assertEquals(FilterReply.NEUTRAL, mkt.decide(nulEvent)); // test a logging event with the CONFIDENTIAL marker LoggingEvent confidentialEvent = new LoggingEvent(); confidentialEvent.setMarker(SecurityMarkers.CONFIDENTIAL); assertEquals(FilterReply.DENY, mkt.decide(confidentialEvent)); // test a logging event with the RESTRICTED marker LoggingEvent restrictedEvent = new LoggingEvent(); restrictedEvent.setMarker(SecurityMarkers.RESTRICTED); assertEquals(FilterReply.DENY, mkt.decide(restrictedEvent)); // test a logging event with the SECRET marker LoggingEvent secretEvent = new LoggingEvent(); secretEvent.setMarker(SecurityMarkers.SECRET); assertEquals(FilterReply.DENY, mkt.decide(secretEvent)); // test a logging event with the TOP_SECRET marker LoggingEvent topSecretEvent = new LoggingEvent(); topSecretEvent.setMarker(SecurityMarkers.TOP_SECRET); assertEquals(FilterReply.DENY, mkt.decide(topSecretEvent)); // test a logging event without the CONFIDENTIAL marker LoggingEvent normalEvent = new LoggingEvent(); normalEvent.setMarker(SecurityMarkers.EVENT_SUCCESS); assertEquals(FilterReply.NEUTRAL, mkt.decide(nulEvent)); }
Example 9
Source File: SecurityMarkerFilterTest.java From owasp-security-logging with Apache License 2.0 | 5 votes |
@Test public void testRaw() { // create a new marker filter SecurityMarkerFilter mkt = new SecurityMarkerFilter(); mkt.setContext(loggerContext); mkt.start(); assertTrue(mkt.isStarted()); // test a logging event with no markers ILoggingEvent nulEvent = new LoggingEvent(); assertEquals(FilterReply.DENY, mkt.decide(nulEvent)); // test a logging event with the CONFIDENTIAL marker LoggingEvent confidentialEvent = new LoggingEvent(); confidentialEvent.setMarker(SecurityMarkers.SECURITY_SUCCESS); assertEquals(FilterReply.NEUTRAL, mkt.decide(confidentialEvent)); // test a logging event with the RESTRICTED marker LoggingEvent restrictedEvent = new LoggingEvent(); restrictedEvent.setMarker(SecurityMarkers.SECURITY_FAILURE); assertEquals(FilterReply.NEUTRAL, mkt.decide(restrictedEvent)); // test a logging event with the SECRET marker LoggingEvent secretEvent = new LoggingEvent(); secretEvent.setMarker(SecurityMarkers.SECURITY_AUDIT); assertEquals(FilterReply.NEUTRAL, mkt.decide(secretEvent)); }
Example 10
Source File: SecurityMarkerFilterTest.java From owasp-security-logging with Apache License 2.0 | 5 votes |
@Test public void testRawAcceptAll() { // create a new marker filter SecurityMarkerFilter mkt = new SecurityMarkerFilter(); mkt.setContext(loggerContext); mkt.setAcceptAll("true"); mkt.start(); assertTrue(mkt.isStarted()); // test a logging event with no markers ILoggingEvent nulEvent = new LoggingEvent(); assertEquals(FilterReply.DENY, mkt.decide(nulEvent)); // test a logging event with the CONFIDENTIAL marker LoggingEvent confidentialEvent = new LoggingEvent(); confidentialEvent.setMarker(SecurityMarkers.SECURITY_SUCCESS); assertEquals(FilterReply.ACCEPT, mkt.decide(confidentialEvent)); // test a logging event with the RESTRICTED marker LoggingEvent restrictedEvent = new LoggingEvent(); restrictedEvent.setMarker(SecurityMarkers.SECURITY_FAILURE); assertEquals(FilterReply.ACCEPT, mkt.decide(restrictedEvent)); // test a logging event with the SECRET marker LoggingEvent secretEvent = new LoggingEvent(); secretEvent.setMarker(SecurityMarkers.SECURITY_AUDIT); assertEquals(FilterReply.ACCEPT, mkt.decide(secretEvent)); }
Example 11
Source File: MarkerFilterTest.java From owasp-security-logging with Apache License 2.0 | 5 votes |
@Test public void testDecideILoggingEvent() { LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); // create a new marker filter MarkerFilter mkt = new MarkerFilter(); mkt.setContext(lc); mkt.setMarker(SecurityMarkers.CONFIDENTIAL_MARKER_NAME); mkt.setOnMatch(FilterReply.ACCEPT); mkt.setOnMismatch(FilterReply.DENY); mkt.start(); assertTrue(mkt.isStarted()); // test a logging event with no markers ILoggingEvent nulEvent = new LoggingEvent(); assertEquals(FilterReply.DENY, mkt.decide(nulEvent)); // test a logging event with the CONFIDENTIAL marker LoggingEvent confidentialEvent = new LoggingEvent(); confidentialEvent.setMarker(SecurityMarkers.CONFIDENTIAL); assertEquals(FilterReply.ACCEPT, mkt.decide(confidentialEvent)); // test a logging event without the CONFIDENTIAL marker LoggingEvent normalEvent = new LoggingEvent(); normalEvent.setMarker(SecurityMarkers.EVENT_SUCCESS); assertEquals(FilterReply.DENY, mkt.decide(nulEvent)); Logger LOGGER = lc.getLogger(MarkerFilterTest.class); LOGGER.debug(SecurityMarkers.TOP_SECRET, "You should not see this!"); LOGGER.debug(SecurityMarkers.CONFIDENTIAL, "Look at this confidential information!"); }
Example 12
Source File: KonkerLogger.java From konker-platform with Apache License 2.0 | 4 votes |
private void buildLoggingEventAndAppend(String localFQCN, Marker marker, Level level, String msg, Object[] params, Throwable t) { LoggingEvent le = new KonkerLoggingEvent(localFQCN, this, level, msg, t, params); le.setMarker(marker); this.callAppenders(le); }