snaef
asked on
Adding a appender to log4j at runtime
Hello,
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.
Many thanks,
-Scott
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.
Many thanks,
-Scott
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Append to the existing i think
ASKER
Thanks for the help, slit points as both were basically the same answer, but the latter was more detailed. Thanks again!
:-)
ASKER