[slf4j-user] Sending output to a file?

Robert Elliot rob at lidalia.org.uk
Tue Feb 7 10:17:37 CET 2012


The SLF4J API deliberately has no concept of Appenders.  It's a very thin façade, solely for code that wishes to log output, not for code that wants to manage what happens to that output.  You fire a message at a Logger; what that Logger does with it is implementation specific.

If you are using Log4J as your implementation and wish to manage the Log4J appenders programatically then the correct thing to do is to use the Log4J API to do so.  There's a 1:1 mapping between an SLF4J logger and a Log4J logger with the same name.

----- Original Message -----
> From: "Robin Szemeti" <robin at redpoint.org.uk>
> To: slf4j-user at qos.ch
> Sent: Tuesday, 7 February, 2012 2:42:14 AM
> Subject: [slf4j-user] Sending output to a file?
> Hi,
> 
> I have a java project with slf4j with log4j as root logger
> 
> Ive struggles to see how to add a FileAppender throughthe slf4j API,
> basically, after the program starts up and the user chooses which tcp
> port it is going to attach to (command line interactive) I need to
> route the logs to [portnumber]-[datestamp].log
> 
> What I *dont* want to do is mess around with the Appenders in the
> log4j
> xml config file ... but I'm confused as to how to chnage the appender
> via the facade ..
> 
> I have somehting similar to :
> 
> private static final Logger logger =
> LoggerFactory.getLogger(ServerTest.class);
> 
> at the top of each class ...
> 
> clues?
> 
> --
> 
> Best regards,
> 
> Robin Szemeti
> 
> Redpoint Consulting Limited
> 
> 
> E: robin at redpoint.org.uk
> T: +44 (0) 1299 405028
> M: +44 (0) 7971 883371
> 
> CONFIDENTIALITY NOTICE
> The information contained in this e-mail is intended only for the
> 
> confidential use of the above named recipient. If you are not the
> intended recipient or person responsible for delivering it to the
> intended recipient, you have received this communication in error
> and must not distribute or copy it.
> 
> Please accept the sender's apologies, notify the sender immediately
> by return e-mail and delete this communication.
> 
> Thank you.
> 
> _______________________________________________
> slf4j-user mailing list
> slf4j-user at qos.ch
> http://mailman.qos.ch/mailman/listinfo/slf4j-user


More information about the slf4j-user mailing list