[JIRA] Created: (LBCLASSIC-58) Print Logback own erros to System.out if debug is enabled?

Print Logback own erros to System.out if debug is enabled? ---------------------------------------------------------- Key: LBCLASSIC-58 URL: http://jira.qos.ch/browse/LBCLASSIC-58 Project: logback-classic Issue Type: Improvement Reporter: Anton Tagunov Assignee: Logback dev list Priority: Minor Hello Ceki, when debug is enabled lots of messages to to System.out anyway. Do you think it would be a good idea to also print messages going to StatusManager to System.out? Apparently there is huge demand for this feature. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira

[ http://jira.qos.ch/browse/LBCLASSIC-58?page=com.atlassian.jira.plugin.system... ] Diego Louzán commented on LBCLASSIC-58: --------------------------------------- This setting would ease it for first-time users (me being that for the last couple of days). The only way of getting configuration errors information is to poll the StatusManager object, and even that isn't very well documented in the manual / faq. I had to dive through the user/dev lists until finding some advice on how to get full error stack traces. I know the configuration "debug" attribute is documented in the manual and it should log everything to the console but this did not do the trick for me. I ended having code like this in the initialization of my app: /* * Log logback status, so it gets printed in case there is a * configuration error for the logging system. */ LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); StatusPrinter.print(lc); This was the way I used for debugging logback configuration errors in my app.
Print Logback own erros to System.out if debug is enabled? ----------------------------------------------------------
Key: LBCLASSIC-58 URL: http://jira.qos.ch/browse/LBCLASSIC-58 Project: logback-classic Issue Type: Improvement Reporter: Anton Tagunov Assignee: Logback dev list Priority: Minor
Hello Ceki, when debug is enabled lots of messages to to System.out anyway. Do you think it would be a good idea to also print messages going to StatusManager to System.out? Apparently there is huge demand for this feature.
-- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira

[ http://jira.qos.ch/browse/LBCLASSIC-58?page=com.atlassian.jira.plugin.system... ] Ceki Gulcu commented on LBCLASSIC-58: ------------------------------------- Why hasn't the debug attribute work for you? That's surprising... The debug attribute within the configuration tag will cause Joran to print out its status messages when its done configuring logback. The only time that does not work is when the config file can't be found or is not well-formed XML. The event listener approach won't solve that problem (assuming the listener is specified within the config file). However, if you programmatically set the listener, e.g. LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); lc.getStatusManager().addStatusListener(new MySystemOutPrintingListener()); which is not very different than what you had previously LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); StatusPrinter.print(lc); Moreover, for the listener to have an affect for cases the debug attribute does not work, the listener must have been set before logback configuration occurs, which would be relatively tricky to accomplish. I am under the impression that listeners do not provide an answer to the problem you seem to be describing.
Print Logback own erros to System.out if debug is enabled? ----------------------------------------------------------
Key: LBCLASSIC-58 URL: http://jira.qos.ch/browse/LBCLASSIC-58 Project: logback-classic Issue Type: Improvement Reporter: Anton Tagunov Assignee: Logback dev list Priority: Minor
Hello Ceki, when debug is enabled lots of messages to to System.out anyway. Do you think it would be a good idea to also print messages going to StatusManager to System.out? Apparently there is huge demand for this feature.
-- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira

[ http://jira.qos.ch/browse/LBCLASSIC-58?page=com.atlassian.jira.plugin.system... ] Ceki Gulcu commented on LBCLASSIC-58: ------------------------------------- How about if the user could enable a listener by setting a system property, say logback.statusListenerClass="...SysoutStatusListener" ?
Print Logback own erros to System.out if debug is enabled? ----------------------------------------------------------
Key: LBCLASSIC-58 URL: http://jira.qos.ch/browse/LBCLASSIC-58 Project: logback-classic Issue Type: Improvement Reporter: Anton Tagunov Assignee: Logback dev list Priority: Minor
Hello Ceki, when debug is enabled lots of messages to to System.out anyway. Do you think it would be a good idea to also print messages going to StatusManager to System.out? Apparently there is huge demand for this feature.
-- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira

[ http://jira.qos.ch/browse/LBCLASSIC-58?page=com.atlassian.jira.plugin.system... ] Joern Huxhorn commented on LBCLASSIC-58: ---------------------------------------- I've just seen your latest changes from revision 1741 . Very nice! How about adding SYSERR (logging to System.err instead of (System.out) in addition to SYSOUT?
Print Logback own erros to System.out if debug is enabled? ----------------------------------------------------------
Key: LBCLASSIC-58 URL: http://jira.qos.ch/browse/LBCLASSIC-58 Project: logback-classic Issue Type: Improvement Reporter: Anton Tagunov Assignee: Logback dev list Priority: Minor
Hello Ceki, when debug is enabled lots of messages to to System.out anyway. Do you think it would be a good idea to also print messages going to StatusManager to System.out? Apparently there is huge demand for this feature.
-- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira

[ http://jira.qos.ch/browse/LBCLASSIC-58?page=com.atlassian.jira.plugin.system... ] Diego Louzán commented on LBCLASSIC-58: --------------------------------------- The debug attribute does not work because logback will fail to log status errors when the xml file is ill-formed or when some appender fails due to misconfiguration (this last statement about appenders is a generalization based on DBAppender behaviour, it may be the case it's a DBAppender bug). Suppose a configuration like this one: <configuration debug="true"> [...] <!-- DB appender --> <appender name="DB" class="ch.qos.logback.classic.db.DBAppender"> <connectionSource class="ch.qos.logback.core.db.JNDIConnectionSource"> <param name="jndiLocation" value="java:comp/env/jdbc/test-ds"/> </connectionSource> [...] </configuration> In my case, running inside tomcat if the jndi location is wrong, logback will silently fail without logging anything. That's why I had to add the StatusPrinter call in the initialization of my app, just logging logback status so I could trace configuration errors. Besides that, I guess that "debug=true" will also enable other debug statements, which I don't want in a production environment. It's just needed to log logback state, not enabling debug status. I've seen your last changes adding an event listener in a system property. Maybe it would be interesting to enable the SYSOUT or SYSERR listener by default? In my case, I would need to enable the listener by adding the system property to tomcat initialization script, which is far from ideal. I guess it will be the same in other scenarios, where you can't rely on having control of the initialization script, thus making it difficult to set a system property (j2ee containers for instance). I can't really tell a good solution to this because my knowledge of logback architecture is limited.
Print Logback own erros to System.out if debug is enabled? ----------------------------------------------------------
Key: LBCLASSIC-58 URL: http://jira.qos.ch/browse/LBCLASSIC-58 Project: logback-classic Issue Type: Improvement Reporter: Anton Tagunov Assignee: Logback dev list Priority: Minor
Hello Ceki, when debug is enabled lots of messages to to System.out anyway. Do you think it would be a good idea to also print messages going to StatusManager to System.out? Apparently there is huge demand for this feature.
-- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira

[ http://jira.qos.ch/browse/LBCLASSIC-58?page=com.atlassian.jira.plugin.system... ] Diego Louzán commented on LBCLASSIC-58: --------------------------------------- Maybe one solution would be, if the system property is not set, fallback to check if a logback defined equivalent env-entry parameter is set using jndi? That way any j2ee container will be able to add listeners without using system properties. Furthermore, this setting would be context-limited as env-entry params are defined per webapp context, unlike system properties which are global to the application. Anyway, this still feels "overkill" to me, I mean, it should be default behaviour to log logback status if any problem occurs while initializating.
Print Logback own erros to System.out if debug is enabled? ----------------------------------------------------------
Key: LBCLASSIC-58 URL: http://jira.qos.ch/browse/LBCLASSIC-58 Project: logback-classic Issue Type: Improvement Reporter: Anton Tagunov Assignee: Logback dev list Priority: Minor
Hello Ceki, when debug is enabled lots of messages to to System.out anyway. Do you think it would be a good idea to also print messages going to StatusManager to System.out? Apparently there is huge demand for this feature.
-- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira

[ http://jira.qos.ch/browse/LBCLASSIC-58?page=com.atlassian.jira.plugin.system... ] Ceki Gulcu commented on LBCLASSIC-58: ------------------------------------- Hello Diego, Your remark about joran (logback's configuration system) failing silently in case of an exception thrown during configuration is surprising but true. It looks like joran will stop processing if it encounters an unchecked exceptions. In particular, it will not print its internal status when configuration debugging is set to true. Your other observation about debug="true" is incorrect. Setting <configuration debug="true"> instructs joran to print its internal status when its done configuring. It has nothing to do with logging statements. Thus, you can leave <configuration debug="true"> in production. As for setting a listener via jndi env-entries, it's an extension of the current problem. I'd like to nail the initial problem before tackling extensions.
Anyway, this still feels "overkill" to me, I mean, it should be default behaviour to log logback status if any problem occurs while initializating.
That's quite reasonable. However, there is a downside to this approach. If the user decides to print out the internal status messages as you have done, they will be printed twice. One can probably come up with other scenarios leading to duplicate output.
Print Logback own erros to System.out if debug is enabled? ----------------------------------------------------------
Key: LBCLASSIC-58 URL: http://jira.qos.ch/browse/LBCLASSIC-58 Project: logback-classic Issue Type: Improvement Reporter: Anton Tagunov Assignee: Logback dev list Priority: Minor
Hello Ceki, when debug is enabled lots of messages to to System.out anyway. Do you think it would be a good idea to also print messages going to StatusManager to System.out? Apparently there is huge demand for this feature.
-- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira

[ http://jira.qos.ch/browse/LBCLASSIC-58?page=com.atlassian.jira.plugin.system... ] Ceki Gulcu commented on LBCLASSIC-58: ------------------------------------- After spending a bit more time on this, I think that automatically printing internal status information in case of errors might not not be such a great idea. First, there would be no easy way to turn this feature off. Second, if the status data is printed automatically and there is noone to read it, then we are just printing noise. The current situation where you actively need to seek status information might not be so bad after all. Here is a procedure covering possible cases: 1) ill formed xml -> print internal status consisting of a single status message 2) exception thrown during configuration -> catch so that configuration can proceed to the end 3) print status data only if asked to with "<configuration debug='true'>". If item 2 is implemented correctly, then status data will always be printed 4) improved documentation, in particular by mentioning the StatusPrinter.print(lc) method
Print Logback own erros to System.out if debug is enabled? ----------------------------------------------------------
Key: LBCLASSIC-58 URL: http://jira.qos.ch/browse/LBCLASSIC-58 Project: logback-classic Issue Type: Improvement Reporter: Anton Tagunov Assignee: Logback dev list Priority: Minor
Hello Ceki, when debug is enabled lots of messages to to System.out anyway. Do you think it would be a good idea to also print messages going to StatusManager to System.out? Apparently there is huge demand for this feature.
-- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira

[ http://jira.qos.ch/browse/LBCLASSIC-58?page=com.atlassian.jira.plugin.system... ] Joern Huxhorn commented on LBCLASSIC-58: ---------------------------------------- After thinking about it, how about printing any configuration errors to System.err by default? I already had to tell five people about StatusManager and the code to get error messages when they asked me "why Lilith" did not work ;) Usually, System.err is appended to the error log in servers and that's what I would expect in case of a configuration mistake.
Print Logback own erros to System.out if debug is enabled? ----------------------------------------------------------
Key: LBCLASSIC-58 URL: http://jira.qos.ch/browse/LBCLASSIC-58 Project: logback-classic Issue Type: Improvement Reporter: Anton Tagunov Assignee: Logback dev list Priority: Minor
Hello Ceki, when debug is enabled lots of messages to to System.out anyway. Do you think it would be a good idea to also print messages going to StatusManager to System.out? Apparently there is huge demand for this feature.
-- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira

[ http://jira.qos.ch/browse/LBCLASSIC-58?page=com.atlassian.jira.plugin.system... ] Syvalta commented on LBCLASSIC-58: ---------------------------------- I would also be in favor of printing configuration errors to System.err by default. System property for controlling that is not very useful in most cases when the application runs at application server.
Print Logback own erros to System.out if debug is enabled? ----------------------------------------------------------
Key: LBCLASSIC-58 URL: http://jira.qos.ch/browse/LBCLASSIC-58 Project: logback-classic Issue Type: Improvement Reporter: Anton Tagunov Assignee: Logback dev list Priority: Minor
Hello Ceki, when debug is enabled lots of messages to to System.out anyway. Do you think it would be a good idea to also print messages going to StatusManager to System.out? Apparently there is huge demand for this feature.
-- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira

[ http://jira.qos.ch/browse/LBCLASSIC-58?page=com.atlassian.jira.plugin.system... ] Ceki Gulcu commented on LBCLASSIC-58: ------------------------------------- As of revision 1767, logback-classic will print its status data in case of errors during initialization.
Print Logback own erros to System.out if debug is enabled? ----------------------------------------------------------
Key: LBCLASSIC-58 URL: http://jira.qos.ch/browse/LBCLASSIC-58 Project: logback-classic Issue Type: Improvement Reporter: Anton Tagunov Assignee: Logback dev list Priority: Minor
Hello Ceki, when debug is enabled lots of messages to to System.out anyway. Do you think it would be a good idea to also print messages going to StatusManager to System.out? Apparently there is huge demand for this feature.
-- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira

[ http://jira.qos.ch/browse/LBCLASSIC-58?page=com.atlassian.jira.plugin.system... ] Ceki Gulcu resolved LBCLASSIC-58. --------------------------------- Resolution: Fixed fixed in revision 1767
Print Logback own erros to System.out if debug is enabled? ----------------------------------------------------------
Key: LBCLASSIC-58 URL: http://jira.qos.ch/browse/LBCLASSIC-58 Project: logback-classic Issue Type: Improvement Reporter: Anton Tagunov Assignee: Logback dev list Priority: Minor
Hello Ceki, when debug is enabled lots of messages to to System.out anyway. Do you think it would be a good idea to also print messages going to StatusManager to System.out? Apparently there is huge demand for this feature.
-- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira

[ http://jira.qos.ch/browse/LBCLASSIC-58?page=com.atlassian.jira.plugin.system... ] Anton Tagunov commented on LBCLASSIC-58: ---------------------------------------- Ceki, what if an error happens after the initialization is complete? Will it be logged to stdout/stderr? If debug is on? Please note http://jira.qos.ch/browse/LBCLASSIC-69 We've only noticed that after we've written our own non-standard Appender which logs to System.out. When we were using vanilla appenders the errors were going totally unnoticed. We were just silently loosing all TRACE messages.
Print Logback own erros to System.out if debug is enabled? ----------------------------------------------------------
Key: LBCLASSIC-58 URL: http://jira.qos.ch/browse/LBCLASSIC-58 Project: logback-classic Issue Type: Improvement Reporter: Anton Tagunov Assignee: Logback dev list Priority: Minor
Hello Ceki, when debug is enabled lots of messages to to System.out anyway. Do you think it would be a good idea to also print messages going to StatusManager to System.out? Apparently there is huge demand for this feature.
-- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
participants (5)
-
Anton Tagunov (JIRA)
-
Ceki Gulcu (JIRA)
-
Diego Louzán (JIRA)
-
Joern Huxhorn (JIRA)
-
Syvalta (JIRA)