Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-201

write a special line as the first line in any log file so that the file can be automatically parsed by a tool

    XMLWordPrintable

Details

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • None
    • logback-core
    • None

    Description

      So there's a few tools out there for parsing log files; most of them require the user to create a regex or find the right line of some config file to figure out what the Pattern layout expression was used to create the log file. The problem with these is the regex/patterns are quite brittle; its easy for code/dependencies to change and new log configuration to become effective or for users to not know the correct config/pattern for a file. (Its easy to have quite a few log configuration files in a tarball/war/bundle and not be quite sure which one is really active in a container for example).

      A simpler idea would be to (optionally but hopefully by default) output the first line of every log file some kind of well known first line (which can easily be excluded by tools that grep for stuff or whatever) which describes the pattern layout thats being used to write the file - so files generated by logback would be automatically parseable by a generic tool. Indeed it'd be nice to have such a tool; so you can easily load a file and turn it into ILoggingEvent objects by parsing the first line...

      e.g. imaging if all the files (including rolling logs and whatnot) looked like this...

      #logback.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %-32.32C %4L | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n
      11:52:08,267 | INFO  | FelixStartLevel  | BlueprintExtender                | rint.container.BlueprintExtender  124 | 9 - org.apache.aries.blueprint - 0.3.1 | No quiesce support is available, so blueprint components will not participate in quiesce operations
      11:52:08,400 | INFO  | rint Extender: 2 | BlueprintContainerImpl           | container.BlueprintContainerImpl  266 | 9 - org.apache.aries.blueprint - 0.3.1 | Bundle org.apache.karaf.management is waiting for namespace handlers 
      11:52:08,704 | INFO  | FelixStartLevel  | jmx                              | ?                                   ? | 27 - org.apache.aries.jmx - 0.3.0 | Starting JMX OSGi agent
      

      so via a simple bit of code the first line (or all lines starting with #logback.) could be parsed to figure out the format of the file; then the rest of the file could be turned into ILogEvents and passed into tools - or rendered easily in the logback eclipse plugin for example.

      Folks could even reverse engineer log formats and make sure other framework/tools/apps output the correct log format up front.

      Then dev/ops can just 'open a log' and its not just text with error prone regex/parsing expressions that have to be guessed but a kinda 'self describing log markup'

      Attachments

        Activity

          People

            ceki Ceki Gülcü
            jstrachan James Strachan
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: