Return-Path: Delivered-To: apmail-logging-log4j-user-archive@www.apache.org Received: (qmail 19421 invoked from network); 27 Aug 2007 14:44:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 27 Aug 2007 14:44:40 -0000 Received: (qmail 48045 invoked by uid 500); 27 Aug 2007 14:44:30 -0000 Delivered-To: apmail-logging-log4j-user-archive@logging.apache.org Received: (qmail 48016 invoked by uid 500); 27 Aug 2007 14:44:30 -0000 Mailing-List: contact log4j-user-help@logging.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Log4J Users List" Reply-To: "Log4J Users List" Delivered-To: mailing list log4j-user@logging.apache.org Received: (qmail 48005 invoked by uid 99); 27 Aug 2007 14:44:30 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Aug 2007 07:44:30 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of hoju@visi.com designates 208.42.176.221 as permitted sender) Received: from [208.42.176.221] (HELO g2host.com) (208.42.176.221) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Aug 2007 14:45:16 +0000 Received: from [162.136.192.1] (account hoju@visi.com) by mailback2.g2host.com (CommuniGate Pro WEBUSER 5.1.10) with HTTP id 6580632 for log4j-user@logging.apache.org; Mon, 27 Aug 2007 09:43:59 -0500 From: "Jacob Kjome" Subject: Re: log4j doesn't recognize my appenders To: "Log4J Users List" X-Mailer: CommuniGate Pro WebUser v5.1.10 Date: Mon, 27 Aug 2007 09:43:59 -0500 Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1;format="flowed" Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org How are you using the Log() class? if you are saying using it the way I think you are using it, you are probably triggering configuration for every instance you get of Log. First, this is a bad pattern. I recommend either using Logger directly or using a wrapper such as commons-logging or SLF4J if you are not keen on declaring dependencies to Log4j everywhere in your code. Second, separate your configuration code from your Logger code. In fact, you could just name your config file log4j.xml, put it in the classpath, and let it get picked up automagically by Log4j. You really don't have to write a single line of configuration code unless you are trying to do something extra special. Oh, and every time you reconfigure, the file pointed at by your file appender will get wiped clean because you have "Append" set to "false". Could explain your empty log file. Correct those issues and let us know if you still have problems. Jake On Mon, 27 Aug 2007 09:59:31 +0200 Alberto.Sanchez.Vera.Saiz@everis.com wrote: > Hi, I'be started usin log4j in one of my apps. In order to use it i've > made a jar file that contains the log4j itself, a Java Stub Class > (Log.java) and a log4j-config,xml inside it. > The problem is that, once i load the config file via domConfigurator and i > instantiate a log object, appears a warning indicating that the logger > doesn't have any appender configured.. > > The configuration part seems to work because the log file defined in the > xml is created, but it's empty. > > The config file looks as this > > > > > > > > > > > > > > > > value="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/> > > > > > > > > > > > > Using this, the code in wich i create log4j is: > > private Logger logger; > > public Log(String userName) { > if (log==null){ > try { > String fichero = "/log4j-config.xml"; > DOMConfigurator domLog = new DOMConfigurator(); > Hierarchy hierarchy = new Hierarchy(new > RootCategory(Level.DEBUG)); > InputStream is = Log.class.getResourceAsStream(fichero); //we > open the XML as an inputStream because it's inside the jar, not the > filesystem > > domLog.doConfigure(is,hierarchy); > > } catch(Exception e) { > e.printStackTrace(); > > } > logger = (Logger) Logger.getInstance(this.getClass().getName()); > } > this.usuario=userName; > } > > I think the problem is related with the way i get the Logger instance, but > i'm not sure --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org For additional commands, e-mail: log4j-user-help@logging.apache.org