Hello. Guys tell me how to organize logging for a separate class. I understand how you can make a common logger for the entire application, and how confused for a particular class. It is not clear how to specify the logger itself, so that it would output information to a specific file.

    1 answer 1

    log4j.properties log4j.appender.file=org.apache.log4j.RollingFileAppender log4j.appender.file.File=D:\\....\log4j-application.log log4j.appender.file.MaxFileSize=5MB log4j.appender.file.MaxBackupIndex=10 log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n 

    So create a logger in the right class:

     final static Logger logger = Logger.getLogger(Classname.class);