Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logging project name dynamically with log4j?

Is it possible to dynamically log the project name using property (like ${project.name} in the appender below)? I'm using log4j.xml configuration file.

If yes, where can I define such a property?

<appender name="console" class="org.apache.log4j.ConsoleAppender">
    <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern"
            value="[${project.name}] %d{ISO8601} [%t] %-5p ..%c{3}.%M(%L)  - %m%n" />
    </layout>
</appender>

By doing this, I'll be able to use the same log4j.xml in all my project.

like image 698
Tahar Avatar asked Oct 06 '22 17:10

Tahar


1 Answers

One way to achieve this would be to build all your projects with Maven and use resource filtering.

(of course Ant can do this as well and probably any other build system as well, but in Maven it's a standard mechanism that is well-known)

like image 83
Sean Patrick Floyd Avatar answered Oct 10 '22 03:10

Sean Patrick Floyd