Skip to content

Log4j2 Logs loglevel followed by '#' sign with complete loglevel package org.apache.log4j.Level #3620

@kommone-bub

Description

@kommone-bub

Description

We have the problem, that that Log4j2 logs for some apache packages/classes like this :

DEBUG#org.apache.log4j.Level
INFO#org.apache.log4j.Level


[A clear and concise description of what the bug is.]

Log4j2 logs like this for some apache classes:

loglevel like DEBUG (that is ok)
then a hash sign # (don't know from where the hash sign is)
then this class path org.apache.log4j.Level

It looks then like this:

.. DEBUG#org.apache.log4j.Level ..

(it may also be the same for INFO level)

Example Logs:

16:25:16,747  DEBUG#org.apache.log4j.Level (org.apache.commons.digester.Digester)- [SetPropertiesRule]{dialogs/dialog/end} Setting property 'name' to 'exitDialog'
16:25:16,747  DEBUG#org.apache.log4j.Level (org.apache.commons.digester.Digester)- [SetPropertiesRule]{dialogs/dialog/end} Set org.apache.shale.dialog.basic.config.EndStateImpl properties
16:25:16,747  DEBUG#org.apache.log4j.Level (org.apache.commons.beanutils.BeanUtils)- BeanUtils.populate(EndState[dialog=<null>,name=null,viewId=null], {name=exitDialog})
16:25:16,747  DEBUG#org.apache.log4j.Level (org.apache.commons.beanutils.ConvertUtils)- Convert string 'exitDialog' to class 'java.lang.String'
16:25:16,747  DEBUG#org.apache.log4j.Level (org.apache.commons.beanutils.converters.StringConverter)- Converting 'String' value 'exitDialog' to type 'String'
16:25:16,747  DEBUG#org.apache.log4j.Level (org.apache.commons.digester.Digester)-   Fire begin() for SetNextRule[methodName=addState, paramType=org.apache.shale.dialog.basic.model.State]
16:25:16,747  DEBUG#org.apache.log4j.Level (org.apache.commons.digester.Digester.sax)- endElement(,,end)
16:25:16,747  DEBUG#org.apache.log4j.Level (org.apache.commons.digester.Digester)-   match='dialogs/dialog/end'
16:25:19,859  INFO#org.apache.log4j.Level (org.apache.shale.dialog.faces.DialogNavigationHandler)- Instantiating DialogNavigationHandler (wrapping instance 'com.sun.faces.application.NavigationHandlerImpl@52184f7c')

We have normal expected log messages like this one, too:

2025-04-17 07:55:26,336  DEBUG (org.apache.struts.util.PropertyMessageResources)- getMessage(de_DE,abrufdatenfeld.geburtsdaten)
2025-04-17 09:36:52,267  INFO  (org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean)- Creating Service {http://www.xoevta.de/xta/xtaws110}XTAInterfaceService from class de.xoevta.xta.xtaws110.XTAInterface

Configuration

As you see the pattern layout is ok, how above pattern is happening?

       <RollingFile name="M99" fileName="${meldeportal-log-dir}/root.log" filePattern="${meldeportal-log-dir}/root.log.%d{yyyy-MM-dd}.    %i.zip">
 11       <PatternLayout pattern="%d  %-5p (%c)- %m%n" charset="UTF-8"/>
 12       <Policies>
 13         <SizeBasedTriggeringPolicy size="100MB"/>
 14       </Policies>
 15       <DefaultRolloverStrategy max="20" fileIndex="max" compressionLevel = "9"/>
 16     </RollingFile>
 17
 18     <RollingFile name="M00" fileName="${meldeportal-log-dir}/apache.log" filePattern="${meldeportal-log-dir}/apache.log.%d{yyyy-MM-    dd}.%i.zip">
 19       <PatternLayout pattern="%d  %-5p (%c)- %m%n" charset="UTF-8"/>
 20       <Policies>
 21         <SizeBasedTriggeringPolicy size="100MB"/>
 22       </Policies>
 23       <DefaultRolloverStrategy max="20" fileIndex="max" compressionLevel = "9"/>
 24     </RollingFile>

Version: [Log4j version]

These are our log4j2 libs that we use (weblogic 12 Server):

log4j-1.2-api-2.24.3.jar
log4j-api-2.24.3.jar
log4j-core-2.24.3.jar

Operating system: [OS and version]
SUSE Linux Enterprise Server 15 SP6

JDK: [JDK distribution and version]
1.8.0_421

Logs

see above

[Stacktraces, errors, etc. relevant applications logs.]

Reproduction

This is difficult to provide because we have a very big application and I do not know so well how to separate that problem.

[An isolated test reproducing the test.
This is difficult to provide because we have a very big application and I do not know so well how to separate that problem.
JUnit tests similar to the ones in the code base are extremely appreciated.]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions