Advertisement
Guest User

Untitled

a guest
Jul 25th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. LoggingFraction loggingFraction = new LoggingFraction()
  2. .consoleHandler(level, "COLOR_PATTERN")
  3. .formatter("PATTERN", "%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%t] (%c{1}) %s%e%n")
  4. .formatter("COLOR_PATTERN", "%K{level}%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%t] (%c{1}) %s%e%n")
  5. .formatter("AUDIT", "%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p (%c{1}) %s%e%n")
  6. .periodicSizeRotatingFileHandler("FILE", h ->{
  7. h.level(level)
  8. .namedFormatter("PATTERN")
  9. .append(true)
  10. .suffix(".yyyy-MM-dd")
  11. .rotateSize(maxSize)
  12. .enabled(true)
  13. .encoding("UTF-8")
  14. .maxBackupIndex(maxFiles);
  15. Map<String,String> fileSpec = new HashMap<>();
  16. fileSpec.put("path", getLogsDirectory() + "/" + "application.log");
  17. h.file(fileSpec);
  18. })
  19. .periodicSizeRotatingFileHandler("FILE_AUDIT", h ->{
  20. h.level(level)
  21. .namedFormatter("AUDIT")
  22. .append(true)
  23. .suffix(".yyyy-MM-dd")
  24. .rotateSize(maxSize)
  25. .enabled(true)
  26. .encoding("UTF-8")
  27. .maxBackupIndex(maxFiles);
  28. Map<String,String> fileSpec = new HashMap<>();
  29. fileSpec.put("path", getLogsDirectory() + "/" + "application-audit.log");
  30. h.file(fileSpec);
  31. })
  32. .rootLogger(l -> {
  33. l.level(level)
  34. .handler("CONSOLE")
  35. .handler("FILE")
  36. ;
  37. })
  38. .logger("FILE_AUDIT", l -> {
  39. l.level(level)
  40. .category("com.company.app.webservice")
  41. .level(Level.INFO)
  42. .handler("FILE_AUDIT")
  43. ;
  44. })
  45. ;
  46.  
  47. private static final Logger LOGGER_AUDIT = LoggerFactory.getLogger("com.company.app.webservice");
  48. ...
  49. LOGGER_AUDIT.info("Testing audit log")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement