1

Is it possible to specify not package based wildcard, but logger name based wildcard in log4j 1.x?

I want something like this:

<logger name="*Reporter" > <level value="INFO"/> <appender-ref ref="ReportFileAppender"/> </logger> 

1 Answer 1

1

No (see section "Logger Hierarchy"). What you are trying to do is to define a set of loggers which is not possible as every logger has its own name.

The following should mimic what you are trying to achieve:

<logger name="Reporter" > <level value="INFO"/> <appender-ref ref="ReportFileAppender"/> </logger> 

In every *Reporter class:

public class MyReporter { private static final Logger logger = LogManager.getLogger("Reporter"); public MyReporter() { logger.debug("foo"); } } 

My gut feeling is that you really should use packages instead.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.