Quoting Chris Chappell <[EMAIL PROTECTED]>:

> Hi
>
> thanks to Jacob for the reply and tips.
>
> I have found that I can use logger.error("etc") as long as it is nested in a
> catch statement.
> If in "straight code" eclipse shows the error.
> I am not sure why this might be - examples on the net show that it should be
> poss.
> However I only need to show exceptions so we can make progess.
>

It makes zero sense that you can only use logger.error("string") within a
"catch" block.  Your Eclipse install or "straight code" plugin is broken.  Try
compiling outside eclipse.  I bet you get no errors no matter where you put
logger.error("string").

> The reason I mentioned TC5.5 was in case the changes in logging had affected
> things- it is a while since I've been developing with java and wanted to
> note the environment I'm using.
>

But Tomcat is the runtime environment.  Your issue is coming at compile-time,
though it's not really a compile-time issue because there's nothing wrong with
the code.  There's something wrong with how Eclipse is interpreting the code as
you view it in the editor.  Given this, the deployment environment is
superfluous to the issue at hand.


Jake

>
>
>
> ----- Original Message -----
> From: "Jacob Kjome" <[EMAIL PROTECTED]>
> To: "Log4J Users List" <log4j-user@logging.apache.org>
> Sent: Monday, March 05, 2007 10:37 PM
> Subject: Re: Log4J and Tomcat 5.5 - Trouble getting started
>
>
> > Quoting Chris Chappell <[EMAIL PROTECTED]>:
> >
> >> Hi
> >>
> >> I'm developing an app with Tomcat 5.5 and am trying to add logging to it.
> >> I've tried lots of things and none seem to work:
> >>
> >> I have code like:
> >>
> >> import java.sql.Connection;
> >> import java.sql.SQLException;
> >> import java.sql.Statement;
> >>
> >> import javax.naming.Context;
> >> import javax.naming.InitialContext;
> >> import javax.sql.DataSource;
> >>
> >> import org.apache.log4j.Logger;
> >>
> >> public class DBConnectivity
> >> {
> >>
> >>     org.apache.log4j.Logger logger =
> >> Logger.getLogger(myapp.DBConnectivity.class);
> >> //also tried org.apache.log4j.Logger logger = Logger.getLogger("MyApp");
> >>     logger.error("Hello");
> >>
> >> Eclipse reports an error for the .error line - saying:
> >>
> >> Syntax error on token "Hello" - delete this token
> >> Syntax error on token(s) misplaced contructs.
> >>
> >
> > Exactly how does this have anything to do with Tomcat 5.5?  Sounds like
> > you are
> > having an issue with Eclipse recognizing the Log4j library.  What you have
> > should work fine, though I would write it simply as...
> >
> > private final transient Logger logger =
> > Logger.getLogger(DBConnectivity.class);
> > logger.error("Hello");
> >
> > Notice that I set the Logger instance as transient. Replace "transient"
> > with
> > "static" if you want your logger to be static.  It's not so important if
> > your
> > enclosing class is not Serializable, but if it is, you need to make sure
> > that
> > loggers aren't serialized with the enclosing class because they are not
> > serializable.
> >
> >
> > Beyond that, I don't know what your issue is.  If this truly is an issue
> > related
> > to Tomcat, you'll need to explain exactly how.
> >
> > Jake
> >
> >>
> >>
> >> The jars in WEB-INF\lib are:
> >>
> >>  commons-beanutils-1.7.0.jar
> >>  commons-codec-1.3.jar
> >>  commons-collections-3.1.jar
> >>  commons-digester-1.7.jar
> >>  commons-el-1.0.jar
> >>  commons-fileupload-1.0.jar
> >>  commons-io-1.1.jar
> >>  commons-lang-2.1.jar
> >>  commons-logging-1.1.jar
> >>  jstl-1.1.0.jar
> >>  log4j-1.2.14.jar
> >>  myfaces-api-1.1.4.jar
> >>  myfaces-impl-1.1.4.jar
> >>  mysql-connector-java-5.0.4-bin.jar
> >>  standard-1.1.2.jar
> >>  tomahawk-1.1.3.jar
> >>
> >> As you can see it is an initial stab at a faces app - is this anything
> >> to do with the prob?
> >>
> >> Any help greatfully recieved
> >>
> >> Chris
> >>
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to