logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ralph Goers (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LOG4J2-776) Using custom path and file name for log4j2 config file in EJB3
Date Sat, 28 Feb 2015 22:30:04 GMT

    [ https://issues.apache.org/jira/browse/LOG4J2-776?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14341811#comment-14341811

Ralph Goers commented on LOG4J2-776:

I'm not sure anything needs to be done here.  I would try having the @Startup bean that looks
like the code below. Note that I haven't compiled it much less tried it. I just copied a sample
Startup class and added the relevant calls you would need to make. Note that there are a few
variations of the initialize method. You should pick the one that best meets your needs. 
Please let us know how this works.

public class StartupBean {
    private States state;
    private LoggerContext context;

    public void initialize() {
        state = States.BEFORESTARTED;
        // Perform intialization
        context = Configurator.initialize("Log4j", "log4j2.xml");
        state = States.STARTED;
        System.out.println("Log4j initialized");
    public void terminate() {
        state = States.SHUTTINGDOWN;
        // Perform termination
        System.out.println("Shut down in progress");
    public States getState() {
        return state;
    public void setState(States state) {
        this.state = state;

> Using custom path and file name for log4j2 config file in EJB3
> --------------------------------------------------------------
>                 Key: LOG4J2-776
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-776
>             Project: Log4j 2
>          Issue Type: New Feature
>          Components: Configurators
>    Affects Versions: 2.0.1
>         Environment: Windows 7, Websphere 8.5, EJB 3.1
>            Reporter: A B
> When using log4j ( 1.x ) with EJB, you could define / set / load the custom log4j configuration
file and define the location of the configuration file by using the @Startup bean with @PostConstruct
and then call PropertyConfigurator.configure(log4jProp); to load the configuration where log4jProp
would be the location AND filename for the config file 
> Since the above method is not valid in log4j2, what method / mechanism should be used
to load a specific configuration in an EJB3 module?
> Also, how can I use an environment / system variable to define the configuration file
name ( as done in Jira item 747 for log4j for a servlet )?
> Thank you,

This message was sent by Atlassian JIRA

To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org

View raw message