I created a new class NewLinePatternLayout.java which extends PatternLayout.java of log4j. Below is my log4j.properties.
log4j.rootLogger=INFO, R
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=${catalina.home}/logs/tomcat.log
log4j.appender.R.MaxFileSize=10MB
log4j.appender.R.MaxBackupIndex=10
log4j.appender.R.layout=com.myCompany.utils.NewLinePatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
I am getting an error as below:
log4j:ERROR The class "org.apache.log4j.Layout" was loaded by
log4j:ERROR [WebappClassLoader
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@620a3d3b
] whereas object of type
log4j:ERROR "com.myCompany.utils.NewLinePatternLayout" was loaded by [org.apache.catalina.loader.StandardClassLoader@620a3d3b].
log4j:ERROR No layout set for the appender named [R].
log4j:ERROR A "com.myCompany.utils.NewLinePatternLayout" object is not assignable to a "org.apache.log4j.Layout" variable.
log4j:ERROR The class "org.apache.log4j.Layout" was loaded by
log4j:ERROR [WebappClassLoader
Please advice on how to solve this issue?