You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2017/01/25 15:52:12 UTC
[2/3] syncope git commit: Fixing LOG4J usage after version upgrade
Fixing LOG4J usage after version upgrade
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/3fe7dc3e
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/3fe7dc3e
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/3fe7dc3e
Branch: refs/heads/master
Commit: 3fe7dc3edfe83d37981ae0c12286520c695882df
Parents: c864bfb
Author: Francesco Chicchiricc� <il...@apache.org>
Authored: Wed Jan 25 16:47:11 2017 +0100
Committer: Francesco Chicchiricc� <il...@apache.org>
Committed: Wed Jan 25 16:47:19 2017 +0100
----------------------------------------------------------------------
.../syncope/core/logic/init/LoggerLoader.java | 36 ++++++++++++--------
1 file changed, 22 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/3fe7dc3e/core/logic/src/main/java/org/apache/syncope/core/logic/init/LoggerLoader.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/init/LoggerLoader.java b/core/logic/src/main/java/org/apache/syncope/core/logic/init/LoggerLoader.java
index 3280fe0..9ab3b7b 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/init/LoggerLoader.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/init/LoggerLoader.java
@@ -27,6 +27,7 @@ import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.Appender;
import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.appender.db.ColumnMapping;
import org.apache.logging.log4j.core.appender.db.jdbc.ColumnConfig;
import org.apache.logging.log4j.core.appender.db.jdbc.ConnectionSource;
import org.apache.logging.log4j.core.appender.db.jdbc.JdbcAppender;
@@ -67,24 +68,31 @@ public class LoggerLoader implements SyncopeLoader {
}
// Audit table and DataSource for each configured domain
- ColumnConfig[] columns = {
- ColumnConfig.createColumnConfig(ctx.getConfiguration(), "EVENT_DATE", null, null, "true", null, null),
- ColumnConfig.createColumnConfig(ctx.getConfiguration(), "LOGGER_LEVEL", "%level", null, null, null, null),
- ColumnConfig.createColumnConfig(ctx.getConfiguration(), "LOGGER", "%logger", null, null, null, null),
- ColumnConfig.createColumnConfig(ctx.getConfiguration(), "MESSAGE", "%message", null, null, null, null),
- ColumnConfig.createColumnConfig(ctx.getConfiguration(), "THROWABLE", "%ex{full}", null, null, null, null)
+ ColumnConfig[] columnConfigs = {
+ ColumnConfig.newBuilder().
+ setConfiguration(ctx.getConfiguration()).setName("EVENT_DATE").setEventTimestamp(true).build(),
+ ColumnConfig.newBuilder().
+ setConfiguration(ctx.getConfiguration()).setName("LOGGER_LEVEL").setPattern("%level").build(),
+ ColumnConfig.newBuilder().
+ setConfiguration(ctx.getConfiguration()).setName("LOGGER").setPattern("%logger").build(),
+ ColumnConfig.newBuilder().
+ setConfiguration(ctx.getConfiguration()).setName("MESSAGE").setPattern("%message").build(),
+ ColumnConfig.newBuilder().
+ setConfiguration(ctx.getConfiguration()).setName("THROWABLE").setPattern("%ex{full}").build()
};
+ ColumnMapping[] columnMappings = new ColumnMapping[0];
for (Map.Entry<String, DataSource> entry : domainsHolder.getDomains().entrySet()) {
Appender appender = ctx.getConfiguration().getAppender("audit_for_" + entry.getKey());
if (appender == null) {
- appender = JdbcAppender.createAppender(
- "audit_for_" + entry.getKey(),
- "false",
- null,
- new DataSourceConnectionSource(entry.getValue()),
- "0",
- "SYNCOPEAUDIT",
- columns);
+ appender = JdbcAppender.newBuilder().
+ withName("audit_for_" + entry.getKey()).
+ withIgnoreExceptions(false).
+ setConnectionSource(new DataSourceConnectionSource(entry.getValue())).
+ setBufferSize(0).
+ setTableName("SYNCOPEAUDIT").
+ setColumnConfigs(columnConfigs).
+ setColumnMappings(columnMappings).
+ build();
appender.start();
ctx.getConfiguration().addAppender(appender);
}