Skip to content

Commit

Permalink
Update Log4JSink Default from sgaudit to audit and add test for defau…
Browse files Browse the repository at this point in the history
…lt values (opensearch-project#4146)

Signed-off-by: Craig Perkins <[email protected]>
  • Loading branch information
cwperks authored Mar 22, 2024
1 parent dd119e5 commit 6f79d09
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public final class Log4JSink extends AuditLogSink {

public Log4JSink(final String name, final Settings settings, final String settingsPrefix, AuditLogSink fallbackSink) {
super(name, settings, settingsPrefix, fallbackSink);
loggerName = settings.get(settingsPrefix + ".log4j.logger_name", "sgaudit");
loggerName = settings.get(settingsPrefix + ".log4j.logger_name", "audit");
auditLogger = LogManager.getLogger(loggerName);
logLevel = Level.toLevel(settings.get(settingsPrefix + ".log4j.level", "INFO").toUpperCase());
enabled = auditLogger.isEnabled(logLevel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ public void testConfiguration() throws Exception {
Assert.assertEquals("loggername", lsink.loggerName);
Assert.assertEquals(Level.DEBUG, lsink.logLevel);

sink = provider.getSink("endpoint13");
Assert.assertEquals(Log4JSink.class, sink.getClass());
lsink = (Log4JSink) sink;
Assert.assertEquals("audit", lsink.loggerName);
Assert.assertEquals(Level.INFO, lsink.logLevel);

}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ plugins.security:
config:
log4j.logger_name: loggername
log4j.level: invalid
endpoint13:
type: log4j

0 comments on commit 6f79d09

Please sign in to comment.