Adding a appender to log4j at runtime
Posted on 2005-03-17
I am new to the log4j package and have a need to add log files at runtime. From looking through the documentation I see that all the logs are configured via a config file. The app will have many users and I would like to create a log file for each user at runtime. I won’t know in advance who the users are.
I thought that I could create a basic rotating file logger and then add appenders to it, but I don’t see a way via the javadocs to create an appender at runtime, just ways to get references to preconfigured appenders.
Is there a way to do this? I guess I could create unique loggers from scratch via code each time a user logs on, but I liked being able to configure the root logger in the config file. The way I understand the docs, a appender will inherit the attributes of the root logger.