• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Anything wrong with the way I use log4j2 that I can't get the debug output of my javamail?

 
Ranch Hand
Posts: 1049
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to debug what is wrong with my java mail which I tried to send using gmail and in localhost my own computer without a web host.

Now, I have log4j2 and log4j inside so I am not sure if I should remove log4j.  

Also, I just want to log to console to see the error:

Here's my log4j2.xml :





Here's my log4j properties file configuration:

And I have further add the SMTP tracing to logging at Tomcat



BUT, I am not getting any error output

And still I can't send out my email or any debug error


Please. I hope someone can help me on this.
 
Ranch Hand
Posts: 218
5
MS IE Notepad Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this code doesn't compile

- classname ends with parenthesis
- session is defined only inside init() but tried to use in sendMail(String) where it's no longer valid
- wrong port - TCP/465 is socket level TLS - StartTLS is for TCP/25 and TCP/587 only
- modern Type 4 JDBC driver no longer need Class.forName() but will be auto-loaded by serviceloader as long it's in classpath at jvm startup time
 
Saloon Keeper
Posts: 28750
211
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, I'm pretty sure that A) Log4j and Log4j2 are mutually exclusive, B) Log4j2 has completely obsoleted log4j C) the log4j2 XML configuration file's default name is simply "log4j.xml".

Consult the documentation, but, as I said, I'm reasonably sure of the above.
 
tangara goh
Ranch Hand
Posts: 1049
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Matt Wong wrote:this code doesn't compile

- classname ends with parenthesis
- session is defined only inside init() but tried to use in sendMail(String) where it's no longer valid
- wrong port - TCP/465 is socket level TLS - StartTLS is for TCP/25 and TCP/587 only
- modern Type 4 JDBC driver no longer need Class.forName() but will be auto-loaded by serviceloader as long it's in classpath at jvm startup time



Thanks for the pointers.

I have since corrected the code.  Basically, I just copied and pasted someone else code whom I thought was working...

However, after including the init portion onto the sendEmai(String) method, I am still getting a null point exception at the line which starts with Store



Why am I getting a null pointer exception in this case.

Furthermore, after removing log4j.properties and now there is only log4j2.xml, I am still not getting any log4j debug output...

Not sure if there is anything wrong with the below log4j2.xml ? (Note: I have changed it to log4j.xml)




Thanking you in advance for your advance.
 
reply
    Bookmark Topic Watch Topic
  • New Topic