Código:
y una properties llamada log4j.propertiespackage log4j; import org.apache.log4j.Logger; import org.apache.log4j.PropertyConfigurator; import java.net.URL; /** * @author jEduardo */ public class Main { static final Logger logger = Logger.getLogger(Main.class); public static void main(String[] args) { URL url = Main.class.getResource("log4j.properties"); PropertyConfigurator.configure(url); logger.debug("Sample debug message"); } }
Código:
pero me genera el siguiente error al realizar la ejecucionlog4j.appender.mail=org.apache.log4j.net.SMTPAppender log4j.appender.mail.BufferSize=1 log4j.appender.mail.SMTPHost=smtp.gmail.com [email protected] [email protected] [email protected] log4j.appender.mail.SMTPPassword=miPassword log4j.appender.mail.SMTPPort=25 log4j.appender.mail.Subject=Log ... log4j.appender.mail.threshold=error log4j.appender.mail.layout=org.apache.log4j.PatternLayout log4j.appender.mail.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n log4j.rootLogger=info, mail
Código:
me gustaria saber que es lo que me genera el error ya que el archivo de propiedades creo que esta correctamente configuradoException in thread "main" java.lang.NoClassDefFoundError: javax/mail/internet/AddressException at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389) at java.lang.Class.getConstructor0(Class.java:2699) at java.lang.Class.newInstance0(Class.java:326) at java.lang.Class.newInstance(Class.java:308) at org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:330) at org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:121) at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:664) at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:647) at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:544) at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:440) at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:476) at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:354) at log4j.Main.main(Main.java:14) Caused by: java.lang.ClassNotFoundException: javax.mail.internet.AddressException at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) ... 14 more Java Result: 1
de ante mano gracias
Saludos !