Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-2549

SMTP fails send messages that originate from main program.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.11.0
    • 2.11.0
    • Appenders
    • None
    • Linux server-2 4.15.0-43-generic #46-Ubuntu SMP Thu Dec 6 14:45:28 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

    Description

      In the course of trying to setup Gmail as the SMTP sender I turned to writing a custom appender basically hacking the SMTP code to add needed features to support TLS using port 587.  I wrote a simple test program that logged a single message from the main program, and, that was it. In the course of debugging my modified SMTP appender I found that the append method which called sendEvents to the manager never got called. So, in the configuration I turned on status="debug", to get more info and the smtpDebug flag set true, as well as using the debugger on my customized appender. I also ran the SMTP appender alongside as comparison. Both appender use the same flow control logic but my custom appender modified the properties values to build the javamail session. With the status debug flags turned on I could also see in both appenders, the sendEvents processing was not being called, which I attribute to the append method not being called at the finish of application operation. I tried various things, finally, based on some old hints that other users reported, tried adding another class and calling a method from the new class in the main program that issued a logger.fatal call. That resulted in indication that the sendEvents logic was now being evoked in the SMTP appender. Now, the send failed because of the lack of TLS support which I have reported in a previous issue, but, this is another problem, that probably is fairly rare since most apps will report errors in some other class than from the main method. 

      Of course, there is a work around since the main method logic can be encapsulated in another class and simply evoked in the main method. I am attaching the custom appender code that I wrote and the testbed code so that you see that it uses the same SMTP flow control as does SMTPappender.

      Attachments

        1. LoggerTest.java
          0.4 kB
          John Scott Brown
        2. GmailManager.java
          12 kB
          John Scott Brown
        3. GmailAppender.java
          7 kB
          John Scott Brown
        4. Foo.java
          0.3 kB
          John Scott Brown

        Activity

          People

            Unassigned Unassigned
            jsbrown51@gmail.com John Scott Brown
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: