Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- LoggingFraction loggingFraction = new LoggingFraction()
- .consoleHandler(level, "COLOR_PATTERN")
- .formatter("PATTERN", "%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%t] (%c{1}) %s%e%n")
- .formatter("COLOR_PATTERN", "%K{level}%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%t] (%c{1}) %s%e%n")
- .formatter("AUDIT", "%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p (%c{1}) %s%e%n")
- .periodicSizeRotatingFileHandler("FILE", h ->{
- h.level(level)
- .namedFormatter("PATTERN")
- .append(true)
- .suffix(".yyyy-MM-dd")
- .rotateSize(maxSize)
- .enabled(true)
- .encoding("UTF-8")
- .maxBackupIndex(maxFiles);
- Map<String,String> fileSpec = new HashMap<>();
- fileSpec.put("path", getLogsDirectory() + "/" + "application.log");
- h.file(fileSpec);
- })
- .periodicSizeRotatingFileHandler("FILE_AUDIT", h ->{
- h.level(level)
- .namedFormatter("AUDIT")
- .append(true)
- .suffix(".yyyy-MM-dd")
- .rotateSize(maxSize)
- .enabled(true)
- .encoding("UTF-8")
- .maxBackupIndex(maxFiles);
- Map<String,String> fileSpec = new HashMap<>();
- fileSpec.put("path", getLogsDirectory() + "/" + "application-audit.log");
- h.file(fileSpec);
- })
- .rootLogger(l -> {
- l.level(level)
- .handler("CONSOLE")
- .handler("FILE")
- ;
- })
- .logger("FILE_AUDIT", l -> {
- l.level(level)
- .category("com.company.app.webservice")
- .level(Level.INFO)
- .handler("FILE_AUDIT")
- ;
- })
- ;
- private static final Logger LOGGER_AUDIT = LoggerFactory.getLogger("com.company.app.webservice");
- ...
- LOGGER_AUDIT.info("Testing audit log")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement