1 2 Previous Next 17 Replies Latest reply on Jan 15, 2007 10:53 PM by None None

    Logging using java.util.logging.*?

    None None Master

      I'm having a very very strange problem: when I run my EAR on my local machine, I get log messages on console. All my beans etc using java.util.logging to send log messages. When I run the exact same EAR file on my production server I get absolute silence on the console from my app. My severe log entries vanish. The JRE's logging.properties is identiical and I can't find any other differences in the setups. Any ideas? Will logging ever be an easy part of the Java debugging process? Should I just use System.out.println instead?

        • 1. Re: Logging using java.util.logging.*?
          None None Master

          I'm wondering if there is any modified version of rt.jar maybe that a) does not allow modification to the java.util.logging.* classes and b) does not allow messages to be intercepted or otherwise be hidden from the console. Logging is supposed to help me debug. I shouldn't have to spend hours debugging logging. Does anyone know a way to absolutely force logger messages to show up on console, without any way for the application to prevent it from happening? I have all my log messages at "severe" priority and yet none of them show up anywhere. Surely Sun created java.util.logging for some purpose?

          • 2. Re: Logging using java.util.logging.*?
            Pete Muir Master

            Why not just use Seam logging (@Logger)? I've never had a problem with this not displaying on the default (ejb3) install of jboss.

            • 3. Re: Logging using java.util.logging.*?
              None None Master

              I could try it, but literally NO messages at all are displaying relating to my applications. Not when they deploy, nothing. Absolute silence. Something is very very wrong. I have long wanted Sun to come up with a way to send log messages to the console with absolute certainty. Instead of working on my software I'm struggling to get logging to work. I guess I will try the @Logger, and System.out. I could also just use a FileWriter or something. It is absurd that Java comes with all these features but still does not have a reliable logging mechanism.

              • 4. Re: Logging using java.util.logging.*?
                None None Master

                It's truly bizzar. I'm looking at the console and I see log messages related to creation of message queues, Tomcat deployment, etc, for all applications EXCEPT my two EAR files. There must be something very strange going on. There really should be a JVM flag like -Xlog-for-real-to-the-console-I-mean-it-this-time that totally prevents any interceptions of log messages. This is insane that I'm spending hours just trying to achieve what used to be possible with "print 'hello there\n'".

                Anyway... time to use a good old FileWriter.

                • 5. Re: Logging using java.util.logging.*?
                  None None Master

                  Even System.out.println is no longer working. This boggles my mind at this point.

                  • 6. Re: Logging using java.util.logging.*?
                    None None Master

                    Success:

                    try {
                     final FileWriter fw = new FileWriter("/tmp/logger.txt");
                     fw.write("log message here, at: " + new java.util.Date() + "\n");
                     fw.close();
                     } catch(Exception e) { }
                    


                    Sun's java.util.logging came out with Java 1.4. You would think they would have some capability like the code I put above.

                    Oh and I can't use @Logger because some of this is happening outside of Seam, like in Servlets. I need to just write my own file logger, like the above.

                    This is so amazing that, even years after 1.4 came out, basic log messages still vanish.


                    • 7. Re: Logging using java.util.logging.*?
                      None None Master

                      Correction: new FileWriter("/tmp/logger.txt", true), so that it will append. I wonder how I can submit this super-secret code to Sun so they might actually make java.util.logging work in a reliable way.

                      • 8. Re: Logging using java.util.logging.*?
                        None None Master

                        I think I know what might be happening. I think there must be a log4j.jar file in one of my ear files because it may be a dependency of something else, which means it has its own classloader which means it isn't picking up the log4j.xml file from jboss.

                        Blah. This stuff is fragile junk. If nothing else a logger should be able to log. If it can't do that, no matter how sophisticated it may be, it is fragile junk.

                        • 9. Re: Logging using java.util.logging.*?
                          Pete Muir Master

                          This is way outside of Seam, but, to me it does sound like you've got a configuration problem on your production server (or your host has).

                          JBoss comes set up to display all the loggers messages correctly (and I'm sure the rest of the servers do as well) so it sounds to me like someone has changed a setting along the way that broke it.

                          I may sound like a broken record, but using Seam logging is IMO, sensible (it will check which loggers are available and choose one). In 1.1.1 you can get a seam logger by

                          LogProvider log = Logging.getLogProvider(...);


                          and should work anywhere.

                          I think 1.1.1 should be out soon

                          • 10. Re: Logging using java.util.logging.*?
                            None None Master

                            I'll certainly be trying 1.1.1 when it comes out.

                            But in this case I'm sure that wouldn't help. In my app, I have:

                            System.out.println: nothing appears
                            java.util.logging.Logger: nothing appears
                            Servlet.log(): nothing appears

                            When all my other apps start up they leave all sorts of chatter about mapping entities, starting message queues, deploying Tomcat, etc. When these two apps deploy, there is NOTHING on the console. I don't even know that they are deploying.

                            So I'm 99.9% certain that @Logger wouldn't make any difference because none of Seam's other messages are showing up either.

                            As I said, log4j is fragile junk. The most important feature of a logging system is to log. I have checked over every config file I can think of checking and I can't see any problem.

                            I'm certain that this is related to virtual hosts and maybe to the way Tomcat handles virtual hosts. I am getting log messages just fine on my other machine here that has only one host entry in the server.xml file. I think I've seen strange behavior like this in Tomcat with virt. hosts before.

                            None of this excuses it; if it takes me a day to figure out why logger.severe("hello") isn't leaving a message, that is broken. Loggers are debugging tools.

                            • 11. Re: Logging using java.util.logging.*?
                              None None Master

                              Anyone have any ideas on this? This is 100% trivially reproducible: when an app is used with a virtual host parameter, not a single log message relating to that app appears anywhere, and nothing you can change in log4j.xml changes that. This is fragile, broken junk. Logging systems exist for the purpose of logging. Surely there is some way to have both virtual hosts AND logging at the same time? I know that in Apache httpd this is easy to do. Debugging a complicated app without any log output at all is like back to the old days of guessing where the problem is, change something, try it again.

                              • 12. Re: Logging using java.util.logging.*?
                                Pete Muir Master

                                I'm going to risk your wrath again and say that this really has nothing to do with Seam and you would be better off taking this to a more relevant forum (either tomcat or jboss as, you don't explicitly say which you are using) as someone might actually know the answer :)

                                I've never used the virtual hosts stuff so can't really be much use - I just use apache proxying and context-paths - which is an alternative you are really stuck and have reasonable control over your environment.

                                I take it you've seen http://www.jboss.org/wiki/Wiki.jsp?page=VirtualHosts? - that seems to have some log config related info...

                                • 13. Re: Logging using java.util.logging.*?
                                  None None Master

                                  Yeah, I'll post this in some other forum. It is certainly a bug and it's very easily reproducible. I need to report it on some other forum. Virt. hosts are working fine. The only two problems I encountered were 1. Seam-managed persistence contexts were not being isolated between apps. I fixed this by using different SMPC names. And 2. Logging stops working entirely.

                                  So I spent about 6 hours so far trying to get a simple log message to work in a virt. host. This isn't a problem with Seam or JBoss. It's a problem with Sun's logging implementation. Logging should be reliable and not sensitive to config settings.

                                  I'm starting to think this is a Tomcat issue because even System.out.println isn't working. What this means is that maybe the console logger is working fine, but the console itself isn't working. I think I have seen this behavior before in Tomcat.

                                  I should maybe write a JNDI logger that sends directly to console and is non-interceptable by anything at the Java layer. This really really should have been including with Sun Java, since the 1.4 days.

                                  • 14. Re: Logging using java.util.logging.*?
                                    None None Master

                                    I have found the problem. It is several layers of fragile junk being mis-labeled as logging systems. The main culprit is Tomcat's new JULI logging system, new since Tomcat 5.5.9 I believe. This piece of junk is a sophisticated system which allows each individual application to have its own logging. Unfortunately it achieves this by not logging anything, and by re-assigning System.out so even println doesn't work anymore.

                                    Now I have to see if there is some way to disable it or force it to actually log log messages.

                                    1 2 Previous Next