2

I've been given the requirement that the first line of my log files must begin with a specific header. This header should specify that this current file is newly created. Even when log files are automatically rotated.

It seems odd but it is in the specification for the project.

Environment info:

  • App Server: Glassfish V2
  • Logging: SL4J
Kevin D
  • 3,564
  • 1
  • 21
  • 38
nikles
  • 21
  • 1
  • 4
  • Potentially related http://stackoverflow.com/questions/6072389/how-to-create-a-own-appender-in-log4j – Kevin D Jan 26 '12 at 10:59

2 Answers2

0

I think you're going to have to subclass the relevant appender and add your own code to do this.

Qwerky
  • 18,217
  • 6
  • 44
  • 80
0

The log file is not written by slf4j. It is written by the logging system behind the facade. The solution will depend on what that logging system is.

Unless that logging system has an existing log file appender that does this, you will need to write a custom appender (using the appropriate API, etc) that writes the header each time it opens a new log file.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216