Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-5672

Avoid using the System.out / System.error PrintStreams for logging

    XMLWordPrintableJSON

    Details

    • Type: Task
    • Status: Resolved
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.11.0
    • Component/s: None
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      Apparently while unit-testing / integration-testing inside the Camel modules the usage of System.out / System.error PrintStream for logging is not a good idea, some reasons for this are:

      • In case you make use of ConsoleAppender inside the module camel-xyz then you get a mix of unformatted System.out / System.error dumps together with the proper logs (having timestamp, thread-name, class-name etc.)
      • In case you make use of an appender other than ConsoleAppender (e.g. FileAppender) then your logs are scattered, partially being inside camel-xyz-test.log and the rest being logged inside your console!
      • Through the proper usage of slf4j API inside tests (instead of System.out / System.error PrintStream) you get much more context information for free (depending on the concrete log4j ConversionPattern you make use of) like the actual thread-name or the class-name etc.
      • Last but not least making use of System.out / System.error PrintStream inside tests brings outputs like the following (as the surefire-plugin runs) which is just annoying:
      Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.193 sec
      Running org.apache.camel.cdi.XmlRoutesFromURLTest
      Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.17 sec
      Running org.apache.camel.cdi.component.properties.PropertiesComponentTest
      This is the output of my System.out.println() call...
      Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.692 sec
      

        Attachments

          Activity

            People

            • Assignee:
              bvahdat Babak Vahdat
              Reporter:
              bvahdat Babak Vahdat
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: