1 2 Previous Next 17 Replies Latest reply: Mar 27, 2007 1:10 PM by DrClap RSS

    log4j + HTMLLayout

    807606
      I am using the HTML layout for logging.

      In the xyzLogger.html file, I find the time in milli seconds, instead of log date and time.

      My props file:
      ########## HTML appender properties ##############
      log4j.appender.htmlIn=org.apache.log4j.RollingFileAppender
      log4j.appender.htmlIn.File=/app/data/nas/lynx/log/xyzLogger.html
      log4j.appender.htmlIn.layout=org.apache.log4j.HTMLLayout
      log4j.appender.htmlIn.layout.LocationInfo=true
      ########## End HTML appender properties ###########
      how can I display the actual date and time instead of milliseconds.

      Thanks in advance
        • 1. Re: log4j + HTMLLayout
          DrClap
          None of the examples in the log4j documentation suggest anything?
          • 2. Re: log4j + HTMLLayout
            807606
            i did a google search and could not find any info.

            Appreciate suggestions....
            • 3. Re: log4j + HTMLLayout
              DrClap
              Amazing. Link to the log4j documentation (first link that comes up when you put those two words into Google):

              http://logging.apache.org/log4j/docs/manual.html

              Load that. Use Control-F in your browser to search for the word "Date".
              • 4. Re: log4j + HTMLLayout
                807606
                Dear Dr..... The link is fine. I am aware of all the links u were talinkg about.

                Pl answer to my question that I could not find in the link u had published here.
                • 5. Re: log4j + HTMLLayout
                  DrClap
                  Well, I'm sorry. If you are going to work in this business you will need to be able to find information from text documents. Are you seriously telling me that even after I told you precisely where to find the information, you still couldn't read it?
                  • 6. Re: log4j + HTMLLayout
                    807606
                    DrClap

                    In fact I have already referred to the link, before I post in the forum.

                    I do not find any where in the document how can I write the property to display in date and time format instead of millisecond.

                    I understand what you mean.

                    Appreciate if you can write a line of code to fix this problem.

                    Thanks in advance
                    • 7. Re: log4j + HTMLLayout
                      807606
                      i am stuck for an answer from an expert.

                      Appreciate help
                      • 8. Re: log4j + HTMLLayout
                        807606
                        You got a perfectly good one. I'm staring directly at the answer you're looking for, you just need to read far enough down the page, and follow the advice that has already been given to you.

                        http://logging.apache.org/log4j/docs/manual.html
                        • 9. Re: log4j + HTMLLayout
                          807606
                          i know how to do it.

                          it has something to do with output format, you should probably check in the documentation how to use their output format strings to accomplish what you need.
                          • 10. Re: log4j + HTMLLayout
                            807606
                            Thanks for the posts.

                            I see the documentation again and could not locate the line you all are referring.

                            Can any one of you just copy and paste the line here?

                            Thanks again.
                            • 11. Re: log4j + HTMLLayout
                              DrClap
                              If you had used Control-F in your browser to search for the word "Date", pressing it twice would have landed you on this line:
                              # Print the date in ISO 8601 format
                              Now, that isn't the line you need. It's a comment. But you should be able to find the line you do need quite close to it.
                              • 12. Re: log4j + HTMLLayout
                                796447
                                If you had used Control-F in your browser to search
                                for the word "Date", pressing it twice would have
                                landed you on this line:
                                # Print the date in ISO 8601 format
                                Now, that isn't the line you need.
                                It's a comment. But you should be able to find the
                                line you do need quite close to it.
                                And I'll bet he'll copy and paste that exact line instead of adapting it to fit the appender name he is configuring.
                                • 13. Re: log4j + HTMLLayout
                                  807606
                                  Dear All
                                  Thanks for the reply.
                                  ########## HTML appender properties ##############
                                  log4j.appender.htmlIn=org.apache.log4j.RollingFileAppender
                                  log4j.appender.htmlIn.File=/app/data/nas/lynx/log/LynxInLogger.html
                                  log4j.appender.htmlIn.layout=org.apache.log4j.HTMLLayout
                                  log4j.appender.htmlIn.layout.LocationInfo=true
                                  log4j.appender.htmlIn.layout.ConversionPattern=%d %-5p %c - %m%n
                                  
                                  log4j.appender.htmlIn.layout.Title=Lynx Interpretations Log
                                  ########## End HTML appender properties ###########
                                  I am getting the following error message and the Html file still displaying milliseconds.


                                  log4j:WARN No such property [conversionPattern] in org.apache.log4j.HTMLLayout.



                                  Appreciate review and help by Gurus.....



                                  Message was edited by:
                                  KSNS

                                  Message was edited by:
                                  KSNS
                                  • 14. Re: log4j + HTMLLayout
                                    jschellSomeoneStoleMyAlias
                                    The referenced examples are using PatternLayout not HTMLLayout.

                                    PatternLayout and HTMLLayout are not the same thing.

                                    And HTMLLayout doesn't derive from PatternLayout.

                                    Not even sure that makes sense. PatternLayout is intended to produce a single line and really just one string from the event. That wouldn't seem to make sense in html.

                                    I would suspect that this would require some custom work. Although there might be some clever configuration that one could do.
                                    1 2 Previous Next