Hi All,
I was trying to use log4j2 logging in OSB. I did below mentioned steps:
- Copied external jars "log4j-api-2.0-beta7" and "log4j-core-2.0-beta7" into %Domain_Home%\lib directory.
- Placed wllog4j.jar into same location.
- Created log4j2.xml and placed it into %Domain_Home% directory.
- Modified setDomainEnv.cmd in %Domain_Home%\bin directory to include log4j2.xml location(set LOG4J_CONFIG_FILE=%DOMAIN_HOME%\log4j2.xml) and enable log4j logging by setting java option(-Dwlw.log.Log4jLoggingEnabled=true)
- Content of log4j2.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<configuration status="debug" name="MyApp" packages="">
<appenders>
<RollingFile name="RollingFile" fileName="C:/Oracle/MiddlewareNew/user_projects/domains/base_domain/servers/AdminServer/logs/services.log" filePattern="logs/$${date:yyyy-MM}/app-%d{yyyy-MM-dd-HH}-%i.log.gz">
<PatternLayout>
<pattern>%d %p %m%n</pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy/>
<SizeBasedTriggeringPolicy size="10 MB"/>
</Policies>
<DefaultRolloverStrategy max="10"/>
</RollingFile>
<Async name="Async">
<appender-ref ref="RollingFile"/>
</Async>
</appenders>
<loggers>
<root level="debug">
<appender-ref ref="Async"/>
</root>
</loggers>
</configuration>
After setting all the above things, when i am starting weblogic server then i am getting parsing exception in console with error like below:
log4j:ERROR Parsing error on line 3 and column 44
log4j:ERROR Document root element "configuration", must match DOCTYPE root "null
".
log4j:ERROR Parsing error on line 3 and column 44
log4j:ERROR Document is invalid: no grammar found.
log4j:WARN The <configuration> element has been deprecated.
log4j:WARN Use the <log4j:configuration> element instead.
I am not able to figure out what is going wrong here. In my information log4j2 has done away with namespaces, schema/dtd references and looks like still weblogic is using log4j 1.2 reference. I would really appreciate of one can tell me what is going wrong here.
There was reference to log4j-1.2.8 in my setDomainEnv.cmd as
set POST_CLASSPATH=%POST_CLASSPATH%;%ALSB_HOME%\lib\version.jar;%ALSB_HOME%\lib\alsb.jar;%ALSB_HOME%\3rdparty\classes;%ALSB_HOME%\lib\external\log4j_1.2.8.jar;%DOMAIN_HOME%\config\osb
could this be causing issue? If yes then how can we remove old references of log4j 1.2(if i am removing this entry from here then log4j is giving error for classes not found).
Any input will be helpful.