You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Kiran Badi <ad...@aayushs.com> on 2015/09/18 18:00:36 UTC

Logging complete exception trace.

Hi All,

I have below log42 xml in classes folder and I am on log4j2 . This setting
does not log exception and it just logs1 line exception.

How do I make log4j2 to log complete exception trace in mysite log ?



<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<configuration>
    <Properties>
         <Property name="log-path">C:/logs/</Property>
<!--       <Property name="log-path">/home/mydrive/logs/</Property>-->
    </Properties>
    <Appenders>
        <RollingFile name="RollingFile" fileName="${log-path}/mysite.log"

 filePattern="${log-path}/indianads-%d{yyyy-MM-dd}-%i.log">
            <PatternLayout>
                <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}:
%m%ex%n</pattern>
            </PatternLayout>
            <Policies>
                <SizeBasedTriggeringPolicy size="1 MB"/>
            </Policies>
            <DefaultRolloverStrategy max="24"/>
        </RollingFile>
    </Appenders>
    <Loggers>
        <Logger name="root" level="debug" additivity="false">
            <appender-ref ref="RollingFile" level="All"/>
        </Logger>
        <Root level="All" additivity="false">
            <AppenderRef ref="RollingFile"/>
        </Root>
    </Loggers>
</configuration>

Re: Logging complete exception trace.

Posted by Kiran Badi <ad...@aayushs.com>.
Ok Remko, Let me make the changes and come back.

On Fri, Sep 18, 2015 at 2:57 PM, Remko Popma <re...@gmail.com> wrote:

> Hmm, your source code looks correct. In your config, you could probably
> remove the named logger entry.
> >>> <Logger name="root" level="debug" additivity="false">
> >>>           <appender-ref ref="RollingFile" level="All"/>
> >>>       </Logger>
>
>
> The <Root> alone is sufficient I think.
> But this won't solve the issue...
>
> Do you see this behavior everywhere or only in some places?
> If you replace %ex in your pattern with %tEx, location info will be added
> to the output. This may help pinpoint the code that generates the log entry
> so you can double check it...
>
> Sorry I don't have a better answer.
>
> Remko
>
> Sent from my iPhone
>
> > On 2015/09/18, at 20:05, Kiran Badi <ad...@aayushs.com> wrote:
> >
> > Thanks Remko for reply, I think that's how I do it.
> >
> > Please see below the way I use it. I am on log4j2 and I have log4j-api,
> > log4j-core and log4j-web jars in the lib directory of my web app.
> >
> > I import these 2 packages
> > import org.apache.logging.log4j.LogManager;
> > import org.apache.logging.log4j.Logger;
> >
> >
> > Create a static instance
> >
> > static final Logger log = LogManager.getLogger(myclass.class.getName());
> >
> > then do use it in class file
> >
> >                  catch (Exception ex) {
> >                         log.error("Got the exception", ex);
> >                    }
> >
> > I was under impression that this should log the complete trace, but its
> not.
> >
> > Any ideas as what I am missing ?
> >
> >
> >
> >
> >> On Fri, Sep 18, 2015 at 1:49 PM, Remko Popma <re...@gmail.com>
> wrote:
> >>
> >> In your application,
> >> do not use logger.error(exception);
> >> but use logger.error("some message", exception); instead.
> >>
> >> The first form will take the exception object as an object and calls
> >> toString() on it, which is not what you want.
> >>
> >> Remko
> >>
> >> Sent from my iPhone
> >>
> >>> On 2015/09/18, at 18:00, Kiran Badi <ad...@aayushs.com> wrote:
> >>>
> >>> Hi All,
> >>>
> >>> I have below log42 xml in classes folder and I am on log4j2 . This
> >> setting
> >>> does not log exception and it just logs1 line exception.
> >>>
> >>> How do I make log4j2 to log complete exception trace in mysite log ?
> >>>
> >>>
> >>>
> >>> <?xml version="1.0" encoding="UTF-8"?>
> >>> <!--
> >>> To change this template, choose Tools | Templates
> >>> and open the template in the editor.
> >>> -->
> >>> <configuration>
> >>>   <Properties>
> >>>        <Property name="log-path">C:/logs/</Property>
> >>> <!--       <Property name="log-path">/home/mydrive/logs/</Property>-->
> >>>   </Properties>
> >>>   <Appenders>
> >>>       <RollingFile name="RollingFile" fileName="${log-path}/mysite.log"
> >>>
> >>> filePattern="${log-path}/indianads-%d{yyyy-MM-dd}-%i.log">
> >>>           <PatternLayout>
> >>>               <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}:
> >>> %m%ex%n</pattern>
> >>>           </PatternLayout>
> >>>           <Policies>
> >>>               <SizeBasedTriggeringPolicy size="1 MB"/>
> >>>           </Policies>
> >>>           <DefaultRolloverStrategy max="24"/>
> >>>       </RollingFile>
> >>>   </Appenders>
> >>>   <Loggers>
> >>>       <Logger name="root" level="debug" additivity="false">
> >>>           <appender-ref ref="RollingFile" level="All"/>
> >>>       </Logger>
> >>>       <Root level="All" additivity="false">
> >>>           <AppenderRef ref="RollingFile"/>
> >>>       </Root>
> >>>   </Loggers>
> >>> </configuration>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> >> For additional commands, e-mail: log4j-user-help@logging.apache.org
> >>
> >>
>

Re: Logging complete exception trace.

Posted by Kiran Badi <ad...@aayushs.com>.
Yes I am on 2.3.

On Friday, September 18, 2015, Remko Popma <re...@gmail.com> wrote:

> Sorry, I made a mistake: %t prints out the Thread. Please replace %tEx
> with %xEx. Can you show the output of that?
>
> Also, what version of log4j are you using? 2.3?
>
> Sent from my iPhone
>
> > On 2015/09/18, at 23:27, Kiran Badi <admin@aayushs.com <javascript:;>>
> wrote:
> >
> > Ok here is the pattern changed  I tried
> >
> > <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}: %m%tEx%n</pattern>
> >
> > After doing this, I got this in logs,
> >
> > 18/Sep/2015 17:23:05,421- myclass: Got the DAO ExceptionError inserting
> > into database. Parameter index out of range (24 > number of parameters,
> > which is 23).http-bio-8084-exec-35Ex
> >
> >
> > All my classes are giving single line exception message,
> >
> > How do I debug this issue now ?
> >
> >
> >
> >
> >
> >> On Fri, Sep 18, 2015 at 2:57 PM, Remko Popma <remko.popma@gmail.com
> <javascript:;>> wrote:
> >>
> >> Hmm, your source code looks correct. In your config, you could probably
> >> remove the named logger entry.
> >>>>> <Logger name="root" level="debug" additivity="false">
> >>>>>          <appender-ref ref="RollingFile" level="All"/>
> >>>>>      </Logger>
> >>
> >>
> >> The <Root> alone is sufficient I think.
> >> But this won't solve the issue...
> >>
> >> Do you see this behavior everywhere or only in some places?
> >> If you replace %ex in your pattern with %tEx, location info will be
> added
> >> to the output. This may help pinpoint the code that generates the log
> entry
> >> so you can double check it...
> >>
> >> Sorry I don't have a better answer.
> >>
> >> Remko
> >>
> >> Sent from my iPhone
> >>
> >>> On 2015/09/18, at 20:05, Kiran Badi <admin@aayushs.com <javascript:;>>
> wrote:
> >>>
> >>> Thanks Remko for reply, I think that's how I do it.
> >>>
> >>> Please see below the way I use it. I am on log4j2 and I have log4j-api,
> >>> log4j-core and log4j-web jars in the lib directory of my web app.
> >>>
> >>> I import these 2 packages
> >>> import org.apache.logging.log4j.LogManager;
> >>> import org.apache.logging.log4j.Logger;
> >>>
> >>>
> >>> Create a static instance
> >>>
> >>> static final Logger log =
> LogManager.getLogger(myclass.class.getName());
> >>>
> >>> then do use it in class file
> >>>
> >>>                 catch (Exception ex) {
> >>>                        log.error("Got the exception", ex);
> >>>                   }
> >>>
> >>> I was under impression that this should log the complete trace, but its
> >> not.
> >>>
> >>> Any ideas as what I am missing ?
> >>>
> >>>
> >>>
> >>>
> >>>> On Fri, Sep 18, 2015 at 1:49 PM, Remko Popma <remko.popma@gmail.com
> <javascript:;>>
> >> wrote:
> >>>>
> >>>> In your application,
> >>>> do not use logger.error(exception);
> >>>> but use logger.error("some message", exception); instead.
> >>>>
> >>>> The first form will take the exception object as an object and calls
> >>>> toString() on it, which is not what you want.
> >>>>
> >>>> Remko
> >>>>
> >>>> Sent from my iPhone
> >>>>
> >>>>> On 2015/09/18, at 18:00, Kiran Badi <admin@aayushs.com
> <javascript:;>> wrote:
> >>>>>
> >>>>> Hi All,
> >>>>>
> >>>>> I have below log42 xml in classes folder and I am on log4j2 . This
> >>>> setting
> >>>>> does not log exception and it just logs1 line exception.
> >>>>>
> >>>>> How do I make log4j2 to log complete exception trace in mysite log ?
> >>>>>
> >>>>>
> >>>>>
> >>>>> <?xml version="1.0" encoding="UTF-8"?>
> >>>>> <!--
> >>>>> To change this template, choose Tools | Templates
> >>>>> and open the template in the editor.
> >>>>> -->
> >>>>> <configuration>
> >>>>>  <Properties>
> >>>>>       <Property name="log-path">C:/logs/</Property>
> >>>>> <!--       <Property
> name="log-path">/home/mydrive/logs/</Property>-->
> >>>>>  </Properties>
> >>>>>  <Appenders>
> >>>>>      <RollingFile name="RollingFile"
> fileName="${log-path}/mysite.log"
> >>>>>
> >>>>> filePattern="${log-path}/indianads-%d{yyyy-MM-dd}-%i.log">
> >>>>>          <PatternLayout>
> >>>>>              <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}:
> >>>>> %m%ex%n</pattern>
> >>>>>          </PatternLayout>
> >>>>>          <Policies>
> >>>>>              <SizeBasedTriggeringPolicy size="1 MB"/>
> >>>>>          </Policies>
> >>>>>          <DefaultRolloverStrategy max="24"/>
> >>>>>      </RollingFile>
> >>>>>  </Appenders>
> >>>>>  <Loggers>
> >>>>>      <Logger name="root" level="debug" additivity="false">
> >>>>>          <appender-ref ref="RollingFile" level="All"/>
> >>>>>      </Logger>
> >>>>>      <Root level="All" additivity="false">
> >>>>>          <AppenderRef ref="RollingFile"/>
> >>>>>      </Root>
> >>>>>  </Loggers>
> >>>>> </configuration>
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> <javascript:;>
> >>>> For additional commands, e-mail: log4j-user-help@logging.apache.org
> <javascript:;>
> >>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> <javascript:;>
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> <javascript:;>
>
>

Re: Logging complete exception trace.

Posted by Kiran Badi <ad...@aayushs.com>.
it's working, you are awesome Ralph. I own you beer mann.

On Saturday, October 10, 2015, Kiran Badi <ad...@aayushs.com> wrote:

> Hah let me check this silly overlook from my end.
>
> On Saturday, October 10, 2015, Ralph Goers <ralph.goers@dslextreme.com
> <javascript:_e(%7B%7D,'cvml','ralph.goers@dslextreme.com');>> wrote:
>
>> In DbUtil.java you have
>>
>> catch (SQLException ex) {
>>    logger.error("Got SQLException" + ex);
>> }
>>
>> You are performing a string concatenation of “Got SQLException” and
>> ex.toString().  ex.toString() essentially will only print the message
>> associated with the exception, which is what you said you are seeing.  If
>> you want the whole stack trace you have to do:
>>
>> logger.error(“Got SQLException”, ex);
>>
>> HTH,
>> Ralph
>>
>>
>> > On Oct 9, 2015, at 10:16 AM, Ralph Goers <ra...@dslextreme.com>
>> wrote:
>> >
>> > Oh darn. Thanks for the reminder. I forgot to look at it when I got
>> home and once again I am at work. I will set a reminder for myself to look
>> at this.
>> >
>> > Ralph
>> >
>> >> On Oct 9, 2015, at 9:35 AM, Kiran Badi <ad...@aayushs.com> wrote:
>> >>
>> >> Thanks Ralph.
>> >>
>> >> Do you see anything which I can change to get it working ?
>> >>
>> >> On Tuesday, October 6, 2015, Ralph Goers <ra...@dslextreme.com>
>> wrote:
>> >>
>> >>> I will try to look at it later this evening when I get home from work.
>> >>>
>> >>> Ralph
>> >>>
>> >>>> On Oct 6, 2015, at 10:02 AM, Kiran Badi <admin@aayushs.com
>> >>> <javascript:;>> wrote:
>> >>>>
>> >>>> Hi,
>> >>>>
>> >>>> I realised the I had zipped all project files and it was not
>> containing
>> >>> the
>> >>>> war file
>> >>>>
>> >>>> I have now copied the war file to this shared drive,
>> >>>>
>> >>>>
>> >>>
>> https://drive.google.com/folderview?id=0B-D3EnvFXkj7OTV2a2t2a1I1dk0&usp=sharing
>> >>>>
>> >>>> Please see if someone can take a look and tell me as what I am doing
>> >>> wrong.
>> >>>>
>> >>>> -kiran
>> >>>>
>> >>>> On Mon, Oct 5, 2015 at 7:55 PM, Kiran Badi <admin@aayushs.com
>> >>> <javascript:;>> wrote:
>> >>>>
>> >>>>> Hi All,
>> >>>>>
>> >>>>> Here is the link for the war file which I have created.
>> >>>>>
>> >>>>> I am on log4j2 2.3 version, tomcat 8.0.15 and JDK 1.7. Example is
>> given
>> >>> as
>> >>>>> close to the issue as what I have in my application.
>> >>>>>
>> >>>>> I have not set the mysql driver so that I get exception whenever I
>> try
>> >>> to
>> >>>>> connect to db.
>> >>>>>
>> >>>>>
>> >>>>>
>> >>>
>> https://drive.google.com/a/aayushs.com/folderview?id=0B-D3EnvFXkj7OTV2a2t2a1I1dk0&usp=sharing
>> >>>>>
>> >>>>> Please let me know as how do I fix this issue.
>> >>>>>
>> >>>>> - Kiran Badi
>> >>>>>
>> >>>>>
>> >>>>> On Mon, Sep 21, 2015 at 8:34 AM, Kiran Badi <admin@aayushs.com
>> >>> <javascript:;>> wrote:
>> >>>>>
>> >>>>>> Ok let me build the sample war file for it and see if I can
>> reproduce
>> >>> it
>> >>>>>> outside of my app.
>> >>>>>>
>> >>>>>> Thanks for hint.
>> >>>>>>
>> >>>>>>
>> >>>>>> On Monday, September 21, 2015, Ralph Goers <
>> ralph.goers@dslextreme.com
>> >>> <javascript:;>>
>> >>>>>> wrote:
>> >>>>>>
>> >>>>>>> Can you provide a sample app that demonstrates this? We have a
>> lot of
>> >>>>>>> tests that don't exhibit this behavior so we really need something
>> >>> not we
>> >>>>>>> can debug.
>> >>>>>>>
>> >>>>>>> Sent from my iPad
>> >>>>>>>
>> >>>>>>>> On Sep 21, 2015, at 5:11 AM, Kiran Badi <admin@aayushs.com
>> >>> <javascript:;>> wrote:
>> >>>>>>>>
>> >>>>>>>> Hi All
>> >>>>>>>>
>> >>>>>>>> How do I debug this issue now.
>> >>>>>>>>
>> >>>>>>>> Appreciate the help since I have log4j2 at many places. So
>> making a
>> >>>>>>> change
>> >>>>>>>> now to logging framework will consume lot of time and I
>> seriously do
>> >>>>>>> not
>> >>>>>>>> have luxury of it.
>> >>>>>>>>
>> >>>>>>>>
>> >>>>>>>>
>> >>>>>>>>> On Saturday, September 19, 2015, Kiran Badi <admin@aayushs.com
>> >>> <javascript:;>>
>> >>>>>>> wrote:
>> >>>>>>>>>
>> >>>>>>>>> Ok I did the change to the pattern and now my pattern looks
>> like,
>> >>>>>>>>>
>> >>>>>>>>> <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{2}: %m%xEx%n</pattern>
>> >>>>>>>>>
>> >>>>>>>>> 19/Sep/2015 09:29:13,975- mypackage.myclass: Got the DAO
>> >>>>>>> ExceptionError
>> >>>>>>>>> inserting data to db. Column count doesn't match value count at
>> row
>> >>> 1
>> >>>>>>>>>
>> >>>>>>>>> No luck :)
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>> On Fri, Sep 18, 2015 at 8:40 PM, Remko Popma <
>> remko.popma@gmail.com
>> >>> <javascript:;>
>> >>>>>>>>> <javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com
>> <javascript:;>');>>
>> >>> wrote:
>> >>>>>>>>>
>> >>>>>>>>>> Sorry, I made a mistake: %t prints out the Thread. Please
>> replace
>> >>>>>>> %tEx
>> >>>>>>>>>> with %xEx. Can you show the output of that?
>> >>>>>>>>>>
>> >>>>>>>>>> Also, what version of log4j are you using? 2.3?
>> >>>>>>>>>>
>> >>>>>>>>>> Sent from my iPhone
>> >>>>>>>>>>
>> >>>>>>>>>>> On 2015/09/18, at 23:27, Kiran Badi <admin@aayushs.com
>> >>> <javascript:;>
>> >>>>>>>>>> <javascript:_e(%7B%7D,'cvml','admin@aayushs.com
>> <javascript:;>');>>
>> >>> wrote:
>> >>>>>>>>>>>
>> >>>>>>>>>>> Ok here is the pattern changed  I tried
>> >>>>>>>>>>>
>> >>>>>>>>>>> <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}:
>> %m%tEx%n</pattern>
>> >>>>>>>>>>>
>> >>>>>>>>>>> After doing this, I got this in logs,
>> >>>>>>>>>>>
>> >>>>>>>>>>> 18/Sep/2015 17:23:05,421- myclass: Got the DAO ExceptionError
>> >>>>>>> inserting
>> >>>>>>>>>>> into database. Parameter index out of range (24 > number of
>> >>>>>>> parameters,
>> >>>>>>>>>>> which is 23).http-bio-8084-exec-35Ex
>> >>>>>>>>>>>
>> >>>>>>>>>>>
>> >>>>>>>>>>> All my classes are giving single line exception message,
>> >>>>>>>>>>>
>> >>>>>>>>>>> How do I debug this issue now ?
>> >>>>>>>>>>>
>> >>>>>>>>>>>
>> >>>>>>>>>>>
>> >>>>>>>>>>>
>> >>>>>>>>>>>
>> >>>>>>>>>>>> On Fri, Sep 18, 2015 at 2:57 PM, Remko Popma <
>> >>>>>>> remko.popma@gmail.com <javascript:;>
>> >>>>>>>>>> <javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com
>> <javascript:;>');>>
>> >>> wrote:
>> >>>>>>>>>>>>
>> >>>>>>>>>>>> Hmm, your source code looks correct. In your config, you
>> could
>> >>>>>>> probably
>> >>>>>>>>>>>> remove the named logger entry.
>> >>>>>>>>>>>>>>> <Logger name="root" level="debug" additivity="false">
>> >>>>>>>>>>>>>>>      <appender-ref ref="RollingFile" level="All"/>
>> >>>>>>>>>>>>>>>  </Logger>
>> >>>>>>>>>>>>
>> >>>>>>>>>>>>
>> >>>>>>>>>>>> The <Root> alone is sufficient I think.
>> >>>>>>>>>>>> But this won't solve the issue...
>> >>>>>>>>>>>>
>> >>>>>>>>>>>> Do you see this behavior everywhere or only in some places?
>> >>>>>>>>>>>> If you replace %ex in your pattern with %tEx, location info
>> will
>> >>> be
>> >>>>>>>>>> added
>> >>>>>>>>>>>> to the output. This may help pinpoint the code that
>> generates the
>> >>>>>>> log
>> >>>>>>>>>> entry
>> >>>>>>>>>>>> so you can double check it...
>> >>>>>>>>>>>>
>> >>>>>>>>>>>> Sorry I don't have a better answer.
>> >>>>>>>>>>>>
>> >>>>>>>>>>>> Remko
>> >>>>>>>>>>>>
>> >>>>>>>>>>>> Sent from my iPhone
>> >>>>>>>>>>>>
>> >>>>>>>>>>>>> On 2015/09/18, at 20:05, Kiran Badi <admin@aayushs.com
>> >>> <javascript:;>
>> >>>>>>>>>> <javascript:_e(%7B%7D,'cvml','admin@aayushs.com
>> <javascript:;>');>>
>> >>> wrote:
>> >>>>>>>>>>>>>
>> >>>>>>>>>>>>> Thanks Remko for reply, I think that's how I do it.
>> >>>>>>>>>>>>>
>> >>>>>>>>>>>>> Please see below the way I use it. I am on log4j2 and I have
>> >>>>>>>>>> log4j-api,
>> >>>>>>>>>>>>> log4j-core and log4j-web jars in the lib directory of my web
>> >>> app.
>> >>>>>>>>>>>>>
>> >>>>>>>>>>>>> I import these 2 packages
>> >>>>>>>>>>>>> import org.apache.logging.log4j.LogManager;
>> >>>>>>>>>>>>> import org.apache.logging.log4j.Logger;
>> >>>>>>>>>>>>>
>> >>>>>>>>>>>>>
>> >>>>>>>>>>>>> Create a static instance
>> >>>>>>>>>>>>>
>> >>>>>>>>>>>>> static final Logger log =
>> >>>>>>>>>> LogManager.getLogger(myclass.class.getName());
>> >>>>>>>>>>>>>
>> >>>>>>>>>>>>> then do use it in class file
>> >>>>>>>>>>>>>
>> >>>>>>>>>>>>>             catch (Exception ex) {
>> >>>>>>>>>>>>>                    log.error("Got the exception", ex);
>> >>>>>>>>>>>>>               }
>> >>>>>>>>>>>>>
>> >>>>>>>>>>>>> I was under impression that this should log the complete
>> trace,
>> >>>>>>> but
>> >>>>>>>>>> its
>> >>>>>>>>>>>> not.
>> >>>>>>>>>>>>>
>> >>>>>>>>>>>>> Any ideas as what I am missing ?
>> >>>>>>>>>>>>>
>> >>>>>>>>>>>>>
>> >>>>>>>>>>>>>
>> >>>>>>>>>>>>>
>> >>>>>>>>>>>>>> On Fri, Sep 18, 2015 at 1:49 PM, Remko Popma <
>> >>>>>>> remko.popma@gmail.com <javascript:;>
>> >>>>>>>>>> <javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com
>> <javascript:;>
>> >>> ');>>
>> >>>>>>>>>>>> wrote:
>> >>>>>>>>>>>>>>
>> >>>>>>>>>>>>>> In your application,
>> >>>>>>>>>>>>>> do not use logger.error(exception);
>> >>>>>>>>>>>>>> but use logger.error("some message", exception); instead.
>> >>>>>>>>>>>>>>
>> >>>>>>>>>>>>>> The first form will take the exception object as an object
>> and
>> >>>>>>> calls
>> >>>>>>>>>>>>>> toString() on it, which is not what you want.
>> >>>>>>>>>>>>>>
>> >>>>>>>>>>>>>> Remko
>> >>>>>>>>>>>>>>
>> >>>>>>>>>>>>>> Sent from my iPhone
>> >>>>>>>>>>>>>>
>> >>>>>>>>>>>>>>> On 2015/09/18, at 18:00, Kiran Badi <admin@aayushs.com
>> >>> <javascript:;>
>> >>>>>>>>>> <javascript:_e(%7B%7D,'cvml','admin@aayushs.com
>> <javascript:;>');>>
>> >>> wrote:
>> >>>>>>>>>>>>>>>
>> >>>>>>>>>>>>>>> Hi All,
>> >>>>>>>>>>>>>>>
>> >>>>>>>>>>>>>>> I have below log42 xml in classes folder and I am on
>> log4j2 .
>> >>>>>>> This
>> >>>>>>>>>>>>>> setting
>> >>>>>>>>>>>>>>> does not log exception and it just logs1 line exception.
>> >>>>>>>>>>>>>>>
>> >>>>>>>>>>>>>>> How do I make log4j2 to log complete exception trace in
>> mysite
>> >>>>>>> log ?
>> >>>>>>>>>>>>>>>
>> >>>>>>>>>>>>>>>
>> >>>>>>>>>>>>>>>
>> >>>>>>>>>>>>>>> <?xml version="1.0" encoding="UTF-8"?>
>> >>>>>>>>>>>>>>> <!--
>> >>>>>>>>>>>>>>> To change this template, choose Tools | Templates
>> >>>>>>>>>>>>>>> and open the template in the editor.
>> >>>>>>>>>>>>>>> -->
>> >>>>>>>>>>>>>>> <configuration>
>> >>>>>>>>>>>>>>> <Properties>
>> >>>>>>>>>>>>>>>   <Property name="log-path">C:/logs/</Property>
>> >>>>>>>>>>>>>>> <!--       <Property
>> >>>>>>>>>> name="log-path">/home/mydrive/logs/</Property>-->
>> >>>>>>>>>>>>>>> </Properties>
>> >>>>>>>>>>>>>>> <Appenders>
>> >>>>>>>>>>>>>>>  <RollingFile name="RollingFile"
>> >>>>>>>>>> fileName="${log-path}/mysite.log"
>> >>>>>>>>>>>>>>>
>> >>>>>>>>>>>>>>> filePattern="${log-path}/indianads-%d{yyyy-MM-dd}-%i.log">
>> >>>>>>>>>>>>>>>      <PatternLayout>
>> >>>>>>>>>>>>>>>          <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}:
>> >>>>>>>>>>>>>>> %m%ex%n</pattern>
>> >>>>>>>>>>>>>>>      </PatternLayout>
>> >>>>>>>>>>>>>>>      <Policies>
>> >>>>>>>>>>>>>>>          <SizeBasedTriggeringPolicy size="1 MB"/>
>> >>>>>>>>>>>>>>>      </Policies>
>> >>>>>>>>>>>>>>>      <DefaultRolloverStrategy max="24"/>
>> >>>>>>>>>>>>>>>  </RollingFile>
>> >>>>>>>>>>>>>>> </Appenders>
>> >>>>>>>>>>>>>>> <Loggers>
>> >>>>>>>>>>>>>>>  <Logger name="root" level="debug" additivity="false">
>> >>>>>>>>>>>>>>>      <appender-ref ref="RollingFile" level="All"/>
>> >>>>>>>>>>>>>>>  </Logger>
>> >>>>>>>>>>>>>>>  <Root level="All" additivity="false">
>> >>>>>>>>>>>>>>>      <AppenderRef ref="RollingFile"/>
>> >>>>>>>>>>>>>>>  </Root>
>> >>>>>>>>>>>>>>> </Loggers>
>> >>>>>>>>>>>>>>> </configuration>
>> >>>>>>>>>>>>>>
>> >>>>>>>>>>>>>>
>> >>>>>>>
>> ---------------------------------------------------------------------
>> >>>>>>>>>>>>>> To unsubscribe, e-mail:
>> >>>>>>> log4j-user-unsubscribe@logging.apache.org <javascript:;>
>> >>>>>>>>>> <javascript:_e(%7B%7D,'cvml','
>> >>>>>>> log4j-user-unsubscribe@logging.apache.org <javascript:;>');>
>> >>>>>>>>>>>>>> For additional commands, e-mail:
>> >>>>>>> log4j-user-help@logging.apache.org <javascript:;>
>> >>>>>>>>>> <javascript:_e(%7B%7D,'cvml','
>> log4j-user-help@logging.apache.org
>> >>> <javascript:;>');>
>> >>>>>>>>>>>>
>> >>>>>>>>>>
>> >>>>>>>>>>
>> >>> ---------------------------------------------------------------------
>> >>>>>>>>>> To unsubscribe, e-mail:
>> log4j-user-unsubscribe@logging.apache.org
>> >>> <javascript:;>
>> >>>>>>>>>> <javascript:_e(%7B%7D,'cvml','
>> >>>>>>> log4j-user-unsubscribe@logging.apache.org <javascript:;>');>
>> >>>>>>>>>> For additional commands, e-mail:
>> >>> log4j-user-help@logging.apache.org <javascript:;>
>> >>>>>>>>>> <javascript:_e(%7B%7D,'cvml','
>> log4j-user-help@logging.apache.org
>> >>> <javascript:;>');>
>> >>>>>>>>>>
>> >>>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>
>> >>>>>>>
>> >>>>>>>
>> ---------------------------------------------------------------------
>> >>>>>>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> >>> <javascript:;>
>> >>>>>>> For additional commands, e-mail:
>> log4j-user-help@logging.apache.org
>> >>> <javascript:;>
>> >>>>>>>
>> >>>>>>>
>> >>>>>
>> >>>
>> >>>
>> >>>
>> >>> ---------------------------------------------------------------------
>> >>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> >>> <javascript:;>
>> >>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>> >>> <javascript:;>
>> >>>
>> >>>
>> >
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> > For additional commands, e-mail: log4j-user-help@logging.apache.org
>> >
>> >
>>
>>

Re: Logging complete exception trace.

Posted by Kiran Badi <ad...@aayushs.com>.
Hah let me check this silly overlook from my end.

On Saturday, October 10, 2015, Ralph Goers <ra...@dslextreme.com>
wrote:

> In DbUtil.java you have
>
> catch (SQLException ex) {
>    logger.error("Got SQLException" + ex);
> }
>
> You are performing a string concatenation of “Got SQLException” and
> ex.toString().  ex.toString() essentially will only print the message
> associated with the exception, which is what you said you are seeing.  If
> you want the whole stack trace you have to do:
>
> logger.error(“Got SQLException”, ex);
>
> HTH,
> Ralph
>
>
> > On Oct 9, 2015, at 10:16 AM, Ralph Goers <ralph.goers@dslextreme.com
> <javascript:;>> wrote:
> >
> > Oh darn. Thanks for the reminder. I forgot to look at it when I got home
> and once again I am at work. I will set a reminder for myself to look at
> this.
> >
> > Ralph
> >
> >> On Oct 9, 2015, at 9:35 AM, Kiran Badi <admin@aayushs.com
> <javascript:;>> wrote:
> >>
> >> Thanks Ralph.
> >>
> >> Do you see anything which I can change to get it working ?
> >>
> >> On Tuesday, October 6, 2015, Ralph Goers <ralph.goers@dslextreme.com
> <javascript:;>> wrote:
> >>
> >>> I will try to look at it later this evening when I get home from work.
> >>>
> >>> Ralph
> >>>
> >>>> On Oct 6, 2015, at 10:02 AM, Kiran Badi <admin@aayushs.com
> <javascript:;>
> >>> <javascript:;>> wrote:
> >>>>
> >>>> Hi,
> >>>>
> >>>> I realised the I had zipped all project files and it was not
> containing
> >>> the
> >>>> war file
> >>>>
> >>>> I have now copied the war file to this shared drive,
> >>>>
> >>>>
> >>>
> https://drive.google.com/folderview?id=0B-D3EnvFXkj7OTV2a2t2a1I1dk0&usp=sharing
> >>>>
> >>>> Please see if someone can take a look and tell me as what I am doing
> >>> wrong.
> >>>>
> >>>> -kiran
> >>>>
> >>>> On Mon, Oct 5, 2015 at 7:55 PM, Kiran Badi <admin@aayushs.com
> <javascript:;>
> >>> <javascript:;>> wrote:
> >>>>
> >>>>> Hi All,
> >>>>>
> >>>>> Here is the link for the war file which I have created.
> >>>>>
> >>>>> I am on log4j2 2.3 version, tomcat 8.0.15 and JDK 1.7. Example is
> given
> >>> as
> >>>>> close to the issue as what I have in my application.
> >>>>>
> >>>>> I have not set the mysql driver so that I get exception whenever I
> try
> >>> to
> >>>>> connect to db.
> >>>>>
> >>>>>
> >>>>>
> >>>
> https://drive.google.com/a/aayushs.com/folderview?id=0B-D3EnvFXkj7OTV2a2t2a1I1dk0&usp=sharing
> >>>>>
> >>>>> Please let me know as how do I fix this issue.
> >>>>>
> >>>>> - Kiran Badi
> >>>>>
> >>>>>
> >>>>> On Mon, Sep 21, 2015 at 8:34 AM, Kiran Badi <admin@aayushs.com
> <javascript:;>
> >>> <javascript:;>> wrote:
> >>>>>
> >>>>>> Ok let me build the sample war file for it and see if I can
> reproduce
> >>> it
> >>>>>> outside of my app.
> >>>>>>
> >>>>>> Thanks for hint.
> >>>>>>
> >>>>>>
> >>>>>> On Monday, September 21, 2015, Ralph Goers <
> ralph.goers@dslextreme.com <javascript:;>
> >>> <javascript:;>>
> >>>>>> wrote:
> >>>>>>
> >>>>>>> Can you provide a sample app that demonstrates this? We have a lot
> of
> >>>>>>> tests that don't exhibit this behavior so we really need something
> >>> not we
> >>>>>>> can debug.
> >>>>>>>
> >>>>>>> Sent from my iPad
> >>>>>>>
> >>>>>>>> On Sep 21, 2015, at 5:11 AM, Kiran Badi <admin@aayushs.com
> <javascript:;>
> >>> <javascript:;>> wrote:
> >>>>>>>>
> >>>>>>>> Hi All
> >>>>>>>>
> >>>>>>>> How do I debug this issue now.
> >>>>>>>>
> >>>>>>>> Appreciate the help since I have log4j2 at many places. So making
> a
> >>>>>>> change
> >>>>>>>> now to logging framework will consume lot of time and I seriously
> do
> >>>>>>> not
> >>>>>>>> have luxury of it.
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>> On Saturday, September 19, 2015, Kiran Badi <admin@aayushs.com
> <javascript:;>
> >>> <javascript:;>>
> >>>>>>> wrote:
> >>>>>>>>>
> >>>>>>>>> Ok I did the change to the pattern and now my pattern looks like,
> >>>>>>>>>
> >>>>>>>>> <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{2}: %m%xEx%n</pattern>
> >>>>>>>>>
> >>>>>>>>> 19/Sep/2015 09:29:13,975- mypackage.myclass: Got the DAO
> >>>>>>> ExceptionError
> >>>>>>>>> inserting data to db. Column count doesn't match value count at
> row
> >>> 1
> >>>>>>>>>
> >>>>>>>>> No luck :)
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> On Fri, Sep 18, 2015 at 8:40 PM, Remko Popma <
> remko.popma@gmail.com <javascript:;>
> >>> <javascript:;>
> >>>>>>>>> <javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com
> <javascript:;> <javascript:;>');>>
> >>> wrote:
> >>>>>>>>>
> >>>>>>>>>> Sorry, I made a mistake: %t prints out the Thread. Please
> replace
> >>>>>>> %tEx
> >>>>>>>>>> with %xEx. Can you show the output of that?
> >>>>>>>>>>
> >>>>>>>>>> Also, what version of log4j are you using? 2.3?
> >>>>>>>>>>
> >>>>>>>>>> Sent from my iPhone
> >>>>>>>>>>
> >>>>>>>>>>> On 2015/09/18, at 23:27, Kiran Badi <admin@aayushs.com
> <javascript:;>
> >>> <javascript:;>
> >>>>>>>>>> <javascript:_e(%7B%7D,'cvml','admin@aayushs.com <javascript:;>
> <javascript:;>');>>
> >>> wrote:
> >>>>>>>>>>>
> >>>>>>>>>>> Ok here is the pattern changed  I tried
> >>>>>>>>>>>
> >>>>>>>>>>> <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}:
> %m%tEx%n</pattern>
> >>>>>>>>>>>
> >>>>>>>>>>> After doing this, I got this in logs,
> >>>>>>>>>>>
> >>>>>>>>>>> 18/Sep/2015 17:23:05,421- myclass: Got the DAO ExceptionError
> >>>>>>> inserting
> >>>>>>>>>>> into database. Parameter index out of range (24 > number of
> >>>>>>> parameters,
> >>>>>>>>>>> which is 23).http-bio-8084-exec-35Ex
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>> All my classes are giving single line exception message,
> >>>>>>>>>>>
> >>>>>>>>>>> How do I debug this issue now ?
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>> On Fri, Sep 18, 2015 at 2:57 PM, Remko Popma <
> >>>>>>> remko.popma@gmail.com <javascript:;> <javascript:;>
> >>>>>>>>>> <javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com
> <javascript:;> <javascript:;>');>>
> >>> wrote:
> >>>>>>>>>>>>
> >>>>>>>>>>>> Hmm, your source code looks correct. In your config, you could
> >>>>>>> probably
> >>>>>>>>>>>> remove the named logger entry.
> >>>>>>>>>>>>>>> <Logger name="root" level="debug" additivity="false">
> >>>>>>>>>>>>>>>      <appender-ref ref="RollingFile" level="All"/>
> >>>>>>>>>>>>>>>  </Logger>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>> The <Root> alone is sufficient I think.
> >>>>>>>>>>>> But this won't solve the issue...
> >>>>>>>>>>>>
> >>>>>>>>>>>> Do you see this behavior everywhere or only in some places?
> >>>>>>>>>>>> If you replace %ex in your pattern with %tEx, location info
> will
> >>> be
> >>>>>>>>>> added
> >>>>>>>>>>>> to the output. This may help pinpoint the code that generates
> the
> >>>>>>> log
> >>>>>>>>>> entry
> >>>>>>>>>>>> so you can double check it...
> >>>>>>>>>>>>
> >>>>>>>>>>>> Sorry I don't have a better answer.
> >>>>>>>>>>>>
> >>>>>>>>>>>> Remko
> >>>>>>>>>>>>
> >>>>>>>>>>>> Sent from my iPhone
> >>>>>>>>>>>>
> >>>>>>>>>>>>> On 2015/09/18, at 20:05, Kiran Badi <admin@aayushs.com
> <javascript:;>
> >>> <javascript:;>
> >>>>>>>>>> <javascript:_e(%7B%7D,'cvml','admin@aayushs.com <javascript:;>
> <javascript:;>');>>
> >>> wrote:
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> Thanks Remko for reply, I think that's how I do it.
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> Please see below the way I use it. I am on log4j2 and I have
> >>>>>>>>>> log4j-api,
> >>>>>>>>>>>>> log4j-core and log4j-web jars in the lib directory of my web
> >>> app.
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> I import these 2 packages
> >>>>>>>>>>>>> import org.apache.logging.log4j.LogManager;
> >>>>>>>>>>>>> import org.apache.logging.log4j.Logger;
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> Create a static instance
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> static final Logger log =
> >>>>>>>>>> LogManager.getLogger(myclass.class.getName());
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> then do use it in class file
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>             catch (Exception ex) {
> >>>>>>>>>>>>>                    log.error("Got the exception", ex);
> >>>>>>>>>>>>>               }
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> I was under impression that this should log the complete
> trace,
> >>>>>>> but
> >>>>>>>>>> its
> >>>>>>>>>>>> not.
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> Any ideas as what I am missing ?
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>> On Fri, Sep 18, 2015 at 1:49 PM, Remko Popma <
> >>>>>>> remko.popma@gmail.com <javascript:;> <javascript:;>
> >>>>>>>>>> <javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com
> <javascript:;> <javascript:;>
> >>> ');>>
> >>>>>>>>>>>> wrote:
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> In your application,
> >>>>>>>>>>>>>> do not use logger.error(exception);
> >>>>>>>>>>>>>> but use logger.error("some message", exception); instead.
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> The first form will take the exception object as an object
> and
> >>>>>>> calls
> >>>>>>>>>>>>>> toString() on it, which is not what you want.
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> Remko
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> Sent from my iPhone
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> On 2015/09/18, at 18:00, Kiran Badi <admin@aayushs.com
> <javascript:;>
> >>> <javascript:;>
> >>>>>>>>>> <javascript:_e(%7B%7D,'cvml','admin@aayushs.com <javascript:;>
> <javascript:;>');>>
> >>> wrote:
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> Hi All,
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> I have below log42 xml in classes folder and I am on
> log4j2 .
> >>>>>>> This
> >>>>>>>>>>>>>> setting
> >>>>>>>>>>>>>>> does not log exception and it just logs1 line exception.
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> How do I make log4j2 to log complete exception trace in
> mysite
> >>>>>>> log ?
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> <?xml version="1.0" encoding="UTF-8"?>
> >>>>>>>>>>>>>>> <!--
> >>>>>>>>>>>>>>> To change this template, choose Tools | Templates
> >>>>>>>>>>>>>>> and open the template in the editor.
> >>>>>>>>>>>>>>> -->
> >>>>>>>>>>>>>>> <configuration>
> >>>>>>>>>>>>>>> <Properties>
> >>>>>>>>>>>>>>>   <Property name="log-path">C:/logs/</Property>
> >>>>>>>>>>>>>>> <!--       <Property
> >>>>>>>>>> name="log-path">/home/mydrive/logs/</Property>-->
> >>>>>>>>>>>>>>> </Properties>
> >>>>>>>>>>>>>>> <Appenders>
> >>>>>>>>>>>>>>>  <RollingFile name="RollingFile"
> >>>>>>>>>> fileName="${log-path}/mysite.log"
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> filePattern="${log-path}/indianads-%d{yyyy-MM-dd}-%i.log">
> >>>>>>>>>>>>>>>      <PatternLayout>
> >>>>>>>>>>>>>>>          <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}:
> >>>>>>>>>>>>>>> %m%ex%n</pattern>
> >>>>>>>>>>>>>>>      </PatternLayout>
> >>>>>>>>>>>>>>>      <Policies>
> >>>>>>>>>>>>>>>          <SizeBasedTriggeringPolicy size="1 MB"/>
> >>>>>>>>>>>>>>>      </Policies>
> >>>>>>>>>>>>>>>      <DefaultRolloverStrategy max="24"/>
> >>>>>>>>>>>>>>>  </RollingFile>
> >>>>>>>>>>>>>>> </Appenders>
> >>>>>>>>>>>>>>> <Loggers>
> >>>>>>>>>>>>>>>  <Logger name="root" level="debug" additivity="false">
> >>>>>>>>>>>>>>>      <appender-ref ref="RollingFile" level="All"/>
> >>>>>>>>>>>>>>>  </Logger>
> >>>>>>>>>>>>>>>  <Root level="All" additivity="false">
> >>>>>>>>>>>>>>>      <AppenderRef ref="RollingFile"/>
> >>>>>>>>>>>>>>>  </Root>
> >>>>>>>>>>>>>>> </Loggers>
> >>>>>>>>>>>>>>> </configuration>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>
> ---------------------------------------------------------------------
> >>>>>>>>>>>>>> To unsubscribe, e-mail:
> >>>>>>> log4j-user-unsubscribe@logging.apache.org <javascript:;>
> <javascript:;>
> >>>>>>>>>> <javascript:_e(%7B%7D,'cvml','
> >>>>>>> log4j-user-unsubscribe@logging.apache.org <javascript:;>
> <javascript:;>');>
> >>>>>>>>>>>>>> For additional commands, e-mail:
> >>>>>>> log4j-user-help@logging.apache.org <javascript:;> <javascript:;>
> >>>>>>>>>> <javascript:_e(%7B%7D,'cvml','
> log4j-user-help@logging.apache.org <javascript:;>
> >>> <javascript:;>');>
> >>>>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>> ---------------------------------------------------------------------
> >>>>>>>>>> To unsubscribe, e-mail:
> log4j-user-unsubscribe@logging.apache.org <javascript:;>
> >>> <javascript:;>
> >>>>>>>>>> <javascript:_e(%7B%7D,'cvml','
> >>>>>>> log4j-user-unsubscribe@logging.apache.org <javascript:;>
> <javascript:;>');>
> >>>>>>>>>> For additional commands, e-mail:
> >>> log4j-user-help@logging.apache.org <javascript:;> <javascript:;>
> >>>>>>>>>> <javascript:_e(%7B%7D,'cvml','
> log4j-user-help@logging.apache.org <javascript:;>
> >>> <javascript:;>');>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> ---------------------------------------------------------------------
> >>>>>>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> <javascript:;>
> >>> <javascript:;>
> >>>>>>> For additional commands, e-mail:
> log4j-user-help@logging.apache.org <javascript:;>
> >>> <javascript:;>
> >>>>>>>
> >>>>>>>
> >>>>>
> >>>
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> <javascript:;>
> >>> <javascript:;>
> >>> For additional commands, e-mail: log4j-user-help@logging.apache.org
> <javascript:;>
> >>> <javascript:;>
> >>>
> >>>
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> <javascript:;>
> > For additional commands, e-mail: log4j-user-help@logging.apache.org
> <javascript:;>
> >
> >
>
>

Re: Logging complete exception trace.

Posted by Ralph Goers <ra...@dslextreme.com>.
In DbUtil.java you have 

catch (SQLException ex) {
   logger.error("Got SQLException" + ex);
}

You are performing a string concatenation of “Got SQLException” and ex.toString().  ex.toString() essentially will only print the message associated with the exception, which is what you said you are seeing.  If you want the whole stack trace you have to do:

logger.error(“Got SQLException”, ex);

HTH,
Ralph


> On Oct 9, 2015, at 10:16 AM, Ralph Goers <ra...@dslextreme.com> wrote:
> 
> Oh darn. Thanks for the reminder. I forgot to look at it when I got home and once again I am at work. I will set a reminder for myself to look at this.
> 
> Ralph
> 
>> On Oct 9, 2015, at 9:35 AM, Kiran Badi <ad...@aayushs.com> wrote:
>> 
>> Thanks Ralph.
>> 
>> Do you see anything which I can change to get it working ?
>> 
>> On Tuesday, October 6, 2015, Ralph Goers <ra...@dslextreme.com> wrote:
>> 
>>> I will try to look at it later this evening when I get home from work.
>>> 
>>> Ralph
>>> 
>>>> On Oct 6, 2015, at 10:02 AM, Kiran Badi <admin@aayushs.com
>>> <javascript:;>> wrote:
>>>> 
>>>> Hi,
>>>> 
>>>> I realised the I had zipped all project files and it was not containing
>>> the
>>>> war file
>>>> 
>>>> I have now copied the war file to this shared drive,
>>>> 
>>>> 
>>> https://drive.google.com/folderview?id=0B-D3EnvFXkj7OTV2a2t2a1I1dk0&usp=sharing
>>>> 
>>>> Please see if someone can take a look and tell me as what I am doing
>>> wrong.
>>>> 
>>>> -kiran
>>>> 
>>>> On Mon, Oct 5, 2015 at 7:55 PM, Kiran Badi <admin@aayushs.com
>>> <javascript:;>> wrote:
>>>> 
>>>>> Hi All,
>>>>> 
>>>>> Here is the link for the war file which I have created.
>>>>> 
>>>>> I am on log4j2 2.3 version, tomcat 8.0.15 and JDK 1.7. Example is given
>>> as
>>>>> close to the issue as what I have in my application.
>>>>> 
>>>>> I have not set the mysql driver so that I get exception whenever I try
>>> to
>>>>> connect to db.
>>>>> 
>>>>> 
>>>>> 
>>> https://drive.google.com/a/aayushs.com/folderview?id=0B-D3EnvFXkj7OTV2a2t2a1I1dk0&usp=sharing
>>>>> 
>>>>> Please let me know as how do I fix this issue.
>>>>> 
>>>>> - Kiran Badi
>>>>> 
>>>>> 
>>>>> On Mon, Sep 21, 2015 at 8:34 AM, Kiran Badi <admin@aayushs.com
>>> <javascript:;>> wrote:
>>>>> 
>>>>>> Ok let me build the sample war file for it and see if I can reproduce
>>> it
>>>>>> outside of my app.
>>>>>> 
>>>>>> Thanks for hint.
>>>>>> 
>>>>>> 
>>>>>> On Monday, September 21, 2015, Ralph Goers <ralph.goers@dslextreme.com
>>> <javascript:;>>
>>>>>> wrote:
>>>>>> 
>>>>>>> Can you provide a sample app that demonstrates this? We have a lot of
>>>>>>> tests that don't exhibit this behavior so we really need something
>>> not we
>>>>>>> can debug.
>>>>>>> 
>>>>>>> Sent from my iPad
>>>>>>> 
>>>>>>>> On Sep 21, 2015, at 5:11 AM, Kiran Badi <admin@aayushs.com
>>> <javascript:;>> wrote:
>>>>>>>> 
>>>>>>>> Hi All
>>>>>>>> 
>>>>>>>> How do I debug this issue now.
>>>>>>>> 
>>>>>>>> Appreciate the help since I have log4j2 at many places. So making a
>>>>>>> change
>>>>>>>> now to logging framework will consume lot of time and I seriously do
>>>>>>> not
>>>>>>>> have luxury of it.
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>>> On Saturday, September 19, 2015, Kiran Badi <admin@aayushs.com
>>> <javascript:;>>
>>>>>>> wrote:
>>>>>>>>> 
>>>>>>>>> Ok I did the change to the pattern and now my pattern looks like,
>>>>>>>>> 
>>>>>>>>> <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{2}: %m%xEx%n</pattern>
>>>>>>>>> 
>>>>>>>>> 19/Sep/2015 09:29:13,975- mypackage.myclass: Got the DAO
>>>>>>> ExceptionError
>>>>>>>>> inserting data to db. Column count doesn't match value count at row
>>> 1
>>>>>>>>> 
>>>>>>>>> No luck :)
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> On Fri, Sep 18, 2015 at 8:40 PM, Remko Popma <remko.popma@gmail.com
>>> <javascript:;>
>>>>>>>>> <javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com <javascript:;>');>>
>>> wrote:
>>>>>>>>> 
>>>>>>>>>> Sorry, I made a mistake: %t prints out the Thread. Please replace
>>>>>>> %tEx
>>>>>>>>>> with %xEx. Can you show the output of that?
>>>>>>>>>> 
>>>>>>>>>> Also, what version of log4j are you using? 2.3?
>>>>>>>>>> 
>>>>>>>>>> Sent from my iPhone
>>>>>>>>>> 
>>>>>>>>>>> On 2015/09/18, at 23:27, Kiran Badi <admin@aayushs.com
>>> <javascript:;>
>>>>>>>>>> <javascript:_e(%7B%7D,'cvml','admin@aayushs.com <javascript:;>');>>
>>> wrote:
>>>>>>>>>>> 
>>>>>>>>>>> Ok here is the pattern changed  I tried
>>>>>>>>>>> 
>>>>>>>>>>> <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}: %m%tEx%n</pattern>
>>>>>>>>>>> 
>>>>>>>>>>> After doing this, I got this in logs,
>>>>>>>>>>> 
>>>>>>>>>>> 18/Sep/2015 17:23:05,421- myclass: Got the DAO ExceptionError
>>>>>>> inserting
>>>>>>>>>>> into database. Parameter index out of range (24 > number of
>>>>>>> parameters,
>>>>>>>>>>> which is 23).http-bio-8084-exec-35Ex
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> All my classes are giving single line exception message,
>>>>>>>>>>> 
>>>>>>>>>>> How do I debug this issue now ?
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>>> On Fri, Sep 18, 2015 at 2:57 PM, Remko Popma <
>>>>>>> remko.popma@gmail.com <javascript:;>
>>>>>>>>>> <javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com <javascript:;>');>>
>>> wrote:
>>>>>>>>>>>> 
>>>>>>>>>>>> Hmm, your source code looks correct. In your config, you could
>>>>>>> probably
>>>>>>>>>>>> remove the named logger entry.
>>>>>>>>>>>>>>> <Logger name="root" level="debug" additivity="false">
>>>>>>>>>>>>>>>      <appender-ref ref="RollingFile" level="All"/>
>>>>>>>>>>>>>>>  </Logger>
>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>>> The <Root> alone is sufficient I think.
>>>>>>>>>>>> But this won't solve the issue...
>>>>>>>>>>>> 
>>>>>>>>>>>> Do you see this behavior everywhere or only in some places?
>>>>>>>>>>>> If you replace %ex in your pattern with %tEx, location info will
>>> be
>>>>>>>>>> added
>>>>>>>>>>>> to the output. This may help pinpoint the code that generates the
>>>>>>> log
>>>>>>>>>> entry
>>>>>>>>>>>> so you can double check it...
>>>>>>>>>>>> 
>>>>>>>>>>>> Sorry I don't have a better answer.
>>>>>>>>>>>> 
>>>>>>>>>>>> Remko
>>>>>>>>>>>> 
>>>>>>>>>>>> Sent from my iPhone
>>>>>>>>>>>> 
>>>>>>>>>>>>> On 2015/09/18, at 20:05, Kiran Badi <admin@aayushs.com
>>> <javascript:;>
>>>>>>>>>> <javascript:_e(%7B%7D,'cvml','admin@aayushs.com <javascript:;>');>>
>>> wrote:
>>>>>>>>>>>>> 
>>>>>>>>>>>>> Thanks Remko for reply, I think that's how I do it.
>>>>>>>>>>>>> 
>>>>>>>>>>>>> Please see below the way I use it. I am on log4j2 and I have
>>>>>>>>>> log4j-api,
>>>>>>>>>>>>> log4j-core and log4j-web jars in the lib directory of my web
>>> app.
>>>>>>>>>>>>> 
>>>>>>>>>>>>> I import these 2 packages
>>>>>>>>>>>>> import org.apache.logging.log4j.LogManager;
>>>>>>>>>>>>> import org.apache.logging.log4j.Logger;
>>>>>>>>>>>>> 
>>>>>>>>>>>>> 
>>>>>>>>>>>>> Create a static instance
>>>>>>>>>>>>> 
>>>>>>>>>>>>> static final Logger log =
>>>>>>>>>> LogManager.getLogger(myclass.class.getName());
>>>>>>>>>>>>> 
>>>>>>>>>>>>> then do use it in class file
>>>>>>>>>>>>> 
>>>>>>>>>>>>>             catch (Exception ex) {
>>>>>>>>>>>>>                    log.error("Got the exception", ex);
>>>>>>>>>>>>>               }
>>>>>>>>>>>>> 
>>>>>>>>>>>>> I was under impression that this should log the complete trace,
>>>>>>> but
>>>>>>>>>> its
>>>>>>>>>>>> not.
>>>>>>>>>>>>> 
>>>>>>>>>>>>> Any ideas as what I am missing ?
>>>>>>>>>>>>> 
>>>>>>>>>>>>> 
>>>>>>>>>>>>> 
>>>>>>>>>>>>> 
>>>>>>>>>>>>>> On Fri, Sep 18, 2015 at 1:49 PM, Remko Popma <
>>>>>>> remko.popma@gmail.com <javascript:;>
>>>>>>>>>> <javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com <javascript:;>
>>> ');>>
>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> In your application,
>>>>>>>>>>>>>> do not use logger.error(exception);
>>>>>>>>>>>>>> but use logger.error("some message", exception); instead.
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> The first form will take the exception object as an object and
>>>>>>> calls
>>>>>>>>>>>>>> toString() on it, which is not what you want.
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> Remko
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> Sent from my iPhone
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> On 2015/09/18, at 18:00, Kiran Badi <admin@aayushs.com
>>> <javascript:;>
>>>>>>>>>> <javascript:_e(%7B%7D,'cvml','admin@aayushs.com <javascript:;>');>>
>>> wrote:
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> Hi All,
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> I have below log42 xml in classes folder and I am on log4j2 .
>>>>>>> This
>>>>>>>>>>>>>> setting
>>>>>>>>>>>>>>> does not log exception and it just logs1 line exception.
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> How do I make log4j2 to log complete exception trace in mysite
>>>>>>> log ?
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>>>>>>>>>>>> <!--
>>>>>>>>>>>>>>> To change this template, choose Tools | Templates
>>>>>>>>>>>>>>> and open the template in the editor.
>>>>>>>>>>>>>>> -->
>>>>>>>>>>>>>>> <configuration>
>>>>>>>>>>>>>>> <Properties>
>>>>>>>>>>>>>>>   <Property name="log-path">C:/logs/</Property>
>>>>>>>>>>>>>>> <!--       <Property
>>>>>>>>>> name="log-path">/home/mydrive/logs/</Property>-->
>>>>>>>>>>>>>>> </Properties>
>>>>>>>>>>>>>>> <Appenders>
>>>>>>>>>>>>>>>  <RollingFile name="RollingFile"
>>>>>>>>>> fileName="${log-path}/mysite.log"
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> filePattern="${log-path}/indianads-%d{yyyy-MM-dd}-%i.log">
>>>>>>>>>>>>>>>      <PatternLayout>
>>>>>>>>>>>>>>>          <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}:
>>>>>>>>>>>>>>> %m%ex%n</pattern>
>>>>>>>>>>>>>>>      </PatternLayout>
>>>>>>>>>>>>>>>      <Policies>
>>>>>>>>>>>>>>>          <SizeBasedTriggeringPolicy size="1 MB"/>
>>>>>>>>>>>>>>>      </Policies>
>>>>>>>>>>>>>>>      <DefaultRolloverStrategy max="24"/>
>>>>>>>>>>>>>>>  </RollingFile>
>>>>>>>>>>>>>>> </Appenders>
>>>>>>>>>>>>>>> <Loggers>
>>>>>>>>>>>>>>>  <Logger name="root" level="debug" additivity="false">
>>>>>>>>>>>>>>>      <appender-ref ref="RollingFile" level="All"/>
>>>>>>>>>>>>>>>  </Logger>
>>>>>>>>>>>>>>>  <Root level="All" additivity="false">
>>>>>>>>>>>>>>>      <AppenderRef ref="RollingFile"/>
>>>>>>>>>>>>>>>  </Root>
>>>>>>>>>>>>>>> </Loggers>
>>>>>>>>>>>>>>> </configuration>
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> 
>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>>>>>> To unsubscribe, e-mail:
>>>>>>> log4j-user-unsubscribe@logging.apache.org <javascript:;>
>>>>>>>>>> <javascript:_e(%7B%7D,'cvml','
>>>>>>> log4j-user-unsubscribe@logging.apache.org <javascript:;>');>
>>>>>>>>>>>>>> For additional commands, e-mail:
>>>>>>> log4j-user-help@logging.apache.org <javascript:;>
>>>>>>>>>> <javascript:_e(%7B%7D,'cvml','log4j-user-help@logging.apache.org
>>> <javascript:;>');>
>>>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 
>>> ---------------------------------------------------------------------
>>>>>>>>>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>>> <javascript:;>
>>>>>>>>>> <javascript:_e(%7B%7D,'cvml','
>>>>>>> log4j-user-unsubscribe@logging.apache.org <javascript:;>');>
>>>>>>>>>> For additional commands, e-mail:
>>> log4j-user-help@logging.apache.org <javascript:;>
>>>>>>>>>> <javascript:_e(%7B%7D,'cvml','log4j-user-help@logging.apache.org
>>> <javascript:;>');>
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>>> <javascript:;>
>>>>>>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>>> <javascript:;>
>>>>>>> 
>>>>>>> 
>>>>> 
>>> 
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>>> <javascript:;>
>>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>>> <javascript:;>
>>> 
>>> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
> 


Re: Logging complete exception trace.

Posted by Ralph Goers <ra...@dslextreme.com>.
Oh darn. Thanks for the reminder. I forgot to look at it when I got home and once again I am at work. I will set a reminder for myself to look at this.

Ralph

> On Oct 9, 2015, at 9:35 AM, Kiran Badi <ad...@aayushs.com> wrote:
> 
> Thanks Ralph.
> 
> Do you see anything which I can change to get it working ?
> 
> On Tuesday, October 6, 2015, Ralph Goers <ra...@dslextreme.com> wrote:
> 
>> I will try to look at it later this evening when I get home from work.
>> 
>> Ralph
>> 
>>> On Oct 6, 2015, at 10:02 AM, Kiran Badi <admin@aayushs.com
>> <javascript:;>> wrote:
>>> 
>>> Hi,
>>> 
>>> I realised the I had zipped all project files and it was not containing
>> the
>>> war file
>>> 
>>> I have now copied the war file to this shared drive,
>>> 
>>> 
>> https://drive.google.com/folderview?id=0B-D3EnvFXkj7OTV2a2t2a1I1dk0&usp=sharing
>>> 
>>> Please see if someone can take a look and tell me as what I am doing
>> wrong.
>>> 
>>> -kiran
>>> 
>>> On Mon, Oct 5, 2015 at 7:55 PM, Kiran Badi <admin@aayushs.com
>> <javascript:;>> wrote:
>>> 
>>>> Hi All,
>>>> 
>>>> Here is the link for the war file which I have created.
>>>> 
>>>> I am on log4j2 2.3 version, tomcat 8.0.15 and JDK 1.7. Example is given
>> as
>>>> close to the issue as what I have in my application.
>>>> 
>>>> I have not set the mysql driver so that I get exception whenever I try
>> to
>>>> connect to db.
>>>> 
>>>> 
>>>> 
>> https://drive.google.com/a/aayushs.com/folderview?id=0B-D3EnvFXkj7OTV2a2t2a1I1dk0&usp=sharing
>>>> 
>>>> Please let me know as how do I fix this issue.
>>>> 
>>>> - Kiran Badi
>>>> 
>>>> 
>>>> On Mon, Sep 21, 2015 at 8:34 AM, Kiran Badi <admin@aayushs.com
>> <javascript:;>> wrote:
>>>> 
>>>>> Ok let me build the sample war file for it and see if I can reproduce
>> it
>>>>> outside of my app.
>>>>> 
>>>>> Thanks for hint.
>>>>> 
>>>>> 
>>>>> On Monday, September 21, 2015, Ralph Goers <ralph.goers@dslextreme.com
>> <javascript:;>>
>>>>> wrote:
>>>>> 
>>>>>> Can you provide a sample app that demonstrates this? We have a lot of
>>>>>> tests that don't exhibit this behavior so we really need something
>> not we
>>>>>> can debug.
>>>>>> 
>>>>>> Sent from my iPad
>>>>>> 
>>>>>>> On Sep 21, 2015, at 5:11 AM, Kiran Badi <admin@aayushs.com
>> <javascript:;>> wrote:
>>>>>>> 
>>>>>>> Hi All
>>>>>>> 
>>>>>>> How do I debug this issue now.
>>>>>>> 
>>>>>>> Appreciate the help since I have log4j2 at many places. So making a
>>>>>> change
>>>>>>> now to logging framework will consume lot of time and I seriously do
>>>>>> not
>>>>>>> have luxury of it.
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>>> On Saturday, September 19, 2015, Kiran Badi <admin@aayushs.com
>> <javascript:;>>
>>>>>> wrote:
>>>>>>>> 
>>>>>>>> Ok I did the change to the pattern and now my pattern looks like,
>>>>>>>> 
>>>>>>>> <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{2}: %m%xEx%n</pattern>
>>>>>>>> 
>>>>>>>> 19/Sep/2015 09:29:13,975- mypackage.myclass: Got the DAO
>>>>>> ExceptionError
>>>>>>>> inserting data to db. Column count doesn't match value count at row
>> 1
>>>>>>>> 
>>>>>>>> No luck :)
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>> On Fri, Sep 18, 2015 at 8:40 PM, Remko Popma <remko.popma@gmail.com
>> <javascript:;>
>>>>>>>> <javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com <javascript:;>');>>
>> wrote:
>>>>>>>> 
>>>>>>>>> Sorry, I made a mistake: %t prints out the Thread. Please replace
>>>>>> %tEx
>>>>>>>>> with %xEx. Can you show the output of that?
>>>>>>>>> 
>>>>>>>>> Also, what version of log4j are you using? 2.3?
>>>>>>>>> 
>>>>>>>>> Sent from my iPhone
>>>>>>>>> 
>>>>>>>>>> On 2015/09/18, at 23:27, Kiran Badi <admin@aayushs.com
>> <javascript:;>
>>>>>>>>> <javascript:_e(%7B%7D,'cvml','admin@aayushs.com <javascript:;>');>>
>> wrote:
>>>>>>>>>> 
>>>>>>>>>> Ok here is the pattern changed  I tried
>>>>>>>>>> 
>>>>>>>>>> <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}: %m%tEx%n</pattern>
>>>>>>>>>> 
>>>>>>>>>> After doing this, I got this in logs,
>>>>>>>>>> 
>>>>>>>>>> 18/Sep/2015 17:23:05,421- myclass: Got the DAO ExceptionError
>>>>>> inserting
>>>>>>>>>> into database. Parameter index out of range (24 > number of
>>>>>> parameters,
>>>>>>>>>> which is 23).http-bio-8084-exec-35Ex
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> All my classes are giving single line exception message,
>>>>>>>>>> 
>>>>>>>>>> How do I debug this issue now ?
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>>> On Fri, Sep 18, 2015 at 2:57 PM, Remko Popma <
>>>>>> remko.popma@gmail.com <javascript:;>
>>>>>>>>> <javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com <javascript:;>');>>
>> wrote:
>>>>>>>>>>> 
>>>>>>>>>>> Hmm, your source code looks correct. In your config, you could
>>>>>> probably
>>>>>>>>>>> remove the named logger entry.
>>>>>>>>>>>>>> <Logger name="root" level="debug" additivity="false">
>>>>>>>>>>>>>>       <appender-ref ref="RollingFile" level="All"/>
>>>>>>>>>>>>>>   </Logger>
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> The <Root> alone is sufficient I think.
>>>>>>>>>>> But this won't solve the issue...
>>>>>>>>>>> 
>>>>>>>>>>> Do you see this behavior everywhere or only in some places?
>>>>>>>>>>> If you replace %ex in your pattern with %tEx, location info will
>> be
>>>>>>>>> added
>>>>>>>>>>> to the output. This may help pinpoint the code that generates the
>>>>>> log
>>>>>>>>> entry
>>>>>>>>>>> so you can double check it...
>>>>>>>>>>> 
>>>>>>>>>>> Sorry I don't have a better answer.
>>>>>>>>>>> 
>>>>>>>>>>> Remko
>>>>>>>>>>> 
>>>>>>>>>>> Sent from my iPhone
>>>>>>>>>>> 
>>>>>>>>>>>> On 2015/09/18, at 20:05, Kiran Badi <admin@aayushs.com
>> <javascript:;>
>>>>>>>>> <javascript:_e(%7B%7D,'cvml','admin@aayushs.com <javascript:;>');>>
>> wrote:
>>>>>>>>>>>> 
>>>>>>>>>>>> Thanks Remko for reply, I think that's how I do it.
>>>>>>>>>>>> 
>>>>>>>>>>>> Please see below the way I use it. I am on log4j2 and I have
>>>>>>>>> log4j-api,
>>>>>>>>>>>> log4j-core and log4j-web jars in the lib directory of my web
>> app.
>>>>>>>>>>>> 
>>>>>>>>>>>> I import these 2 packages
>>>>>>>>>>>> import org.apache.logging.log4j.LogManager;
>>>>>>>>>>>> import org.apache.logging.log4j.Logger;
>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>>> Create a static instance
>>>>>>>>>>>> 
>>>>>>>>>>>> static final Logger log =
>>>>>>>>> LogManager.getLogger(myclass.class.getName());
>>>>>>>>>>>> 
>>>>>>>>>>>> then do use it in class file
>>>>>>>>>>>> 
>>>>>>>>>>>>              catch (Exception ex) {
>>>>>>>>>>>>                     log.error("Got the exception", ex);
>>>>>>>>>>>>                }
>>>>>>>>>>>> 
>>>>>>>>>>>> I was under impression that this should log the complete trace,
>>>>>> but
>>>>>>>>> its
>>>>>>>>>>> not.
>>>>>>>>>>>> 
>>>>>>>>>>>> Any ideas as what I am missing ?
>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>>>> On Fri, Sep 18, 2015 at 1:49 PM, Remko Popma <
>>>>>> remko.popma@gmail.com <javascript:;>
>>>>>>>>> <javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com <javascript:;>
>> ');>>
>>>>>>>>>>> wrote:
>>>>>>>>>>>>> 
>>>>>>>>>>>>> In your application,
>>>>>>>>>>>>> do not use logger.error(exception);
>>>>>>>>>>>>> but use logger.error("some message", exception); instead.
>>>>>>>>>>>>> 
>>>>>>>>>>>>> The first form will take the exception object as an object and
>>>>>> calls
>>>>>>>>>>>>> toString() on it, which is not what you want.
>>>>>>>>>>>>> 
>>>>>>>>>>>>> Remko
>>>>>>>>>>>>> 
>>>>>>>>>>>>> Sent from my iPhone
>>>>>>>>>>>>> 
>>>>>>>>>>>>>> On 2015/09/18, at 18:00, Kiran Badi <admin@aayushs.com
>> <javascript:;>
>>>>>>>>> <javascript:_e(%7B%7D,'cvml','admin@aayushs.com <javascript:;>');>>
>> wrote:
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> Hi All,
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> I have below log42 xml in classes folder and I am on log4j2 .
>>>>>> This
>>>>>>>>>>>>> setting
>>>>>>>>>>>>>> does not log exception and it just logs1 line exception.
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> How do I make log4j2 to log complete exception trace in mysite
>>>>>> log ?
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>>>>>>>>>>> <!--
>>>>>>>>>>>>>> To change this template, choose Tools | Templates
>>>>>>>>>>>>>> and open the template in the editor.
>>>>>>>>>>>>>> -->
>>>>>>>>>>>>>> <configuration>
>>>>>>>>>>>>>> <Properties>
>>>>>>>>>>>>>>    <Property name="log-path">C:/logs/</Property>
>>>>>>>>>>>>>> <!--       <Property
>>>>>>>>> name="log-path">/home/mydrive/logs/</Property>-->
>>>>>>>>>>>>>> </Properties>
>>>>>>>>>>>>>> <Appenders>
>>>>>>>>>>>>>>   <RollingFile name="RollingFile"
>>>>>>>>> fileName="${log-path}/mysite.log"
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> filePattern="${log-path}/indianads-%d{yyyy-MM-dd}-%i.log">
>>>>>>>>>>>>>>       <PatternLayout>
>>>>>>>>>>>>>>           <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}:
>>>>>>>>>>>>>> %m%ex%n</pattern>
>>>>>>>>>>>>>>       </PatternLayout>
>>>>>>>>>>>>>>       <Policies>
>>>>>>>>>>>>>>           <SizeBasedTriggeringPolicy size="1 MB"/>
>>>>>>>>>>>>>>       </Policies>
>>>>>>>>>>>>>>       <DefaultRolloverStrategy max="24"/>
>>>>>>>>>>>>>>   </RollingFile>
>>>>>>>>>>>>>> </Appenders>
>>>>>>>>>>>>>> <Loggers>
>>>>>>>>>>>>>>   <Logger name="root" level="debug" additivity="false">
>>>>>>>>>>>>>>       <appender-ref ref="RollingFile" level="All"/>
>>>>>>>>>>>>>>   </Logger>
>>>>>>>>>>>>>>   <Root level="All" additivity="false">
>>>>>>>>>>>>>>       <AppenderRef ref="RollingFile"/>
>>>>>>>>>>>>>>   </Root>
>>>>>>>>>>>>>> </Loggers>
>>>>>>>>>>>>>> </configuration>
>>>>>>>>>>>>> 
>>>>>>>>>>>>> 
>>>>>> ---------------------------------------------------------------------
>>>>>>>>>>>>> To unsubscribe, e-mail:
>>>>>> log4j-user-unsubscribe@logging.apache.org <javascript:;>
>>>>>>>>> <javascript:_e(%7B%7D,'cvml','
>>>>>> log4j-user-unsubscribe@logging.apache.org <javascript:;>');>
>>>>>>>>>>>>> For additional commands, e-mail:
>>>>>> log4j-user-help@logging.apache.org <javascript:;>
>>>>>>>>> <javascript:_e(%7B%7D,'cvml','log4j-user-help@logging.apache.org
>> <javascript:;>');>
>>>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> 
>> ---------------------------------------------------------------------
>>>>>>>>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> <javascript:;>
>>>>>>>>> <javascript:_e(%7B%7D,'cvml','
>>>>>> log4j-user-unsubscribe@logging.apache.org <javascript:;>');>
>>>>>>>>> For additional commands, e-mail:
>> log4j-user-help@logging.apache.org <javascript:;>
>>>>>>>>> <javascript:_e(%7B%7D,'cvml','log4j-user-help@logging.apache.org
>> <javascript:;>');>
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> <javascript:;>
>>>>>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>> <javascript:;>
>>>>>> 
>>>>>> 
>>>> 
>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> <javascript:;>
>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>> <javascript:;>
>> 
>> 



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Logging complete exception trace.

Posted by Kiran Badi <ad...@aayushs.com>.
Thanks Ralph.

Do you see anything which I can change to get it working ?

On Tuesday, October 6, 2015, Ralph Goers <ra...@dslextreme.com> wrote:

> I will try to look at it later this evening when I get home from work.
>
> Ralph
>
> > On Oct 6, 2015, at 10:02 AM, Kiran Badi <admin@aayushs.com
> <javascript:;>> wrote:
> >
> > Hi,
> >
> > I realised the I had zipped all project files and it was not containing
> the
> > war file
> >
> > I have now copied the war file to this shared drive,
> >
> >
> https://drive.google.com/folderview?id=0B-D3EnvFXkj7OTV2a2t2a1I1dk0&usp=sharing
> >
> > Please see if someone can take a look and tell me as what I am doing
> wrong.
> >
> > -kiran
> >
> > On Mon, Oct 5, 2015 at 7:55 PM, Kiran Badi <admin@aayushs.com
> <javascript:;>> wrote:
> >
> >> Hi All,
> >>
> >> Here is the link for the war file which I have created.
> >>
> >> I am on log4j2 2.3 version, tomcat 8.0.15 and JDK 1.7. Example is given
> as
> >> close to the issue as what I have in my application.
> >>
> >> I have not set the mysql driver so that I get exception whenever I try
> to
> >> connect to db.
> >>
> >>
> >>
> https://drive.google.com/a/aayushs.com/folderview?id=0B-D3EnvFXkj7OTV2a2t2a1I1dk0&usp=sharing
> >>
> >> Please let me know as how do I fix this issue.
> >>
> >> - Kiran Badi
> >>
> >>
> >> On Mon, Sep 21, 2015 at 8:34 AM, Kiran Badi <admin@aayushs.com
> <javascript:;>> wrote:
> >>
> >>> Ok let me build the sample war file for it and see if I can reproduce
> it
> >>> outside of my app.
> >>>
> >>> Thanks for hint.
> >>>
> >>>
> >>> On Monday, September 21, 2015, Ralph Goers <ralph.goers@dslextreme.com
> <javascript:;>>
> >>> wrote:
> >>>
> >>>> Can you provide a sample app that demonstrates this? We have a lot of
> >>>> tests that don't exhibit this behavior so we really need something
> not we
> >>>> can debug.
> >>>>
> >>>> Sent from my iPad
> >>>>
> >>>>> On Sep 21, 2015, at 5:11 AM, Kiran Badi <admin@aayushs.com
> <javascript:;>> wrote:
> >>>>>
> >>>>> Hi All
> >>>>>
> >>>>> How do I debug this issue now.
> >>>>>
> >>>>> Appreciate the help since I have log4j2 at many places. So making a
> >>>> change
> >>>>> now to logging framework will consume lot of time and I seriously do
> >>>> not
> >>>>> have luxury of it.
> >>>>>
> >>>>>
> >>>>>
> >>>>>> On Saturday, September 19, 2015, Kiran Badi <admin@aayushs.com
> <javascript:;>>
> >>>> wrote:
> >>>>>>
> >>>>>> Ok I did the change to the pattern and now my pattern looks like,
> >>>>>>
> >>>>>> <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{2}: %m%xEx%n</pattern>
> >>>>>>
> >>>>>> 19/Sep/2015 09:29:13,975- mypackage.myclass: Got the DAO
> >>>> ExceptionError
> >>>>>> inserting data to db. Column count doesn't match value count at row
> 1
> >>>>>>
> >>>>>> No luck :)
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>> On Fri, Sep 18, 2015 at 8:40 PM, Remko Popma <remko.popma@gmail.com
> <javascript:;>
> >>>>>> <javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com <javascript:;>');>>
> wrote:
> >>>>>>
> >>>>>>> Sorry, I made a mistake: %t prints out the Thread. Please replace
> >>>> %tEx
> >>>>>>> with %xEx. Can you show the output of that?
> >>>>>>>
> >>>>>>> Also, what version of log4j are you using? 2.3?
> >>>>>>>
> >>>>>>> Sent from my iPhone
> >>>>>>>
> >>>>>>>> On 2015/09/18, at 23:27, Kiran Badi <admin@aayushs.com
> <javascript:;>
> >>>>>>> <javascript:_e(%7B%7D,'cvml','admin@aayushs.com <javascript:;>');>>
> wrote:
> >>>>>>>>
> >>>>>>>> Ok here is the pattern changed  I tried
> >>>>>>>>
> >>>>>>>> <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}: %m%tEx%n</pattern>
> >>>>>>>>
> >>>>>>>> After doing this, I got this in logs,
> >>>>>>>>
> >>>>>>>> 18/Sep/2015 17:23:05,421- myclass: Got the DAO ExceptionError
> >>>> inserting
> >>>>>>>> into database. Parameter index out of range (24 > number of
> >>>> parameters,
> >>>>>>>> which is 23).http-bio-8084-exec-35Ex
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> All my classes are giving single line exception message,
> >>>>>>>>
> >>>>>>>> How do I debug this issue now ?
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>> On Fri, Sep 18, 2015 at 2:57 PM, Remko Popma <
> >>>> remko.popma@gmail.com <javascript:;>
> >>>>>>> <javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com <javascript:;>');>>
> wrote:
> >>>>>>>>>
> >>>>>>>>> Hmm, your source code looks correct. In your config, you could
> >>>> probably
> >>>>>>>>> remove the named logger entry.
> >>>>>>>>>>>> <Logger name="root" level="debug" additivity="false">
> >>>>>>>>>>>>        <appender-ref ref="RollingFile" level="All"/>
> >>>>>>>>>>>>    </Logger>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> The <Root> alone is sufficient I think.
> >>>>>>>>> But this won't solve the issue...
> >>>>>>>>>
> >>>>>>>>> Do you see this behavior everywhere or only in some places?
> >>>>>>>>> If you replace %ex in your pattern with %tEx, location info will
> be
> >>>>>>> added
> >>>>>>>>> to the output. This may help pinpoint the code that generates the
> >>>> log
> >>>>>>> entry
> >>>>>>>>> so you can double check it...
> >>>>>>>>>
> >>>>>>>>> Sorry I don't have a better answer.
> >>>>>>>>>
> >>>>>>>>> Remko
> >>>>>>>>>
> >>>>>>>>> Sent from my iPhone
> >>>>>>>>>
> >>>>>>>>>> On 2015/09/18, at 20:05, Kiran Badi <admin@aayushs.com
> <javascript:;>
> >>>>>>> <javascript:_e(%7B%7D,'cvml','admin@aayushs.com <javascript:;>');>>
> wrote:
> >>>>>>>>>>
> >>>>>>>>>> Thanks Remko for reply, I think that's how I do it.
> >>>>>>>>>>
> >>>>>>>>>> Please see below the way I use it. I am on log4j2 and I have
> >>>>>>> log4j-api,
> >>>>>>>>>> log4j-core and log4j-web jars in the lib directory of my web
> app.
> >>>>>>>>>>
> >>>>>>>>>> I import these 2 packages
> >>>>>>>>>> import org.apache.logging.log4j.LogManager;
> >>>>>>>>>> import org.apache.logging.log4j.Logger;
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>> Create a static instance
> >>>>>>>>>>
> >>>>>>>>>> static final Logger log =
> >>>>>>> LogManager.getLogger(myclass.class.getName());
> >>>>>>>>>>
> >>>>>>>>>> then do use it in class file
> >>>>>>>>>>
> >>>>>>>>>>               catch (Exception ex) {
> >>>>>>>>>>                      log.error("Got the exception", ex);
> >>>>>>>>>>                 }
> >>>>>>>>>>
> >>>>>>>>>> I was under impression that this should log the complete trace,
> >>>> but
> >>>>>>> its
> >>>>>>>>> not.
> >>>>>>>>>>
> >>>>>>>>>> Any ideas as what I am missing ?
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>> On Fri, Sep 18, 2015 at 1:49 PM, Remko Popma <
> >>>> remko.popma@gmail.com <javascript:;>
> >>>>>>> <javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com <javascript:;>
> ');>>
> >>>>>>>>> wrote:
> >>>>>>>>>>>
> >>>>>>>>>>> In your application,
> >>>>>>>>>>> do not use logger.error(exception);
> >>>>>>>>>>> but use logger.error("some message", exception); instead.
> >>>>>>>>>>>
> >>>>>>>>>>> The first form will take the exception object as an object and
> >>>> calls
> >>>>>>>>>>> toString() on it, which is not what you want.
> >>>>>>>>>>>
> >>>>>>>>>>> Remko
> >>>>>>>>>>>
> >>>>>>>>>>> Sent from my iPhone
> >>>>>>>>>>>
> >>>>>>>>>>>> On 2015/09/18, at 18:00, Kiran Badi <admin@aayushs.com
> <javascript:;>
> >>>>>>> <javascript:_e(%7B%7D,'cvml','admin@aayushs.com <javascript:;>');>>
> wrote:
> >>>>>>>>>>>>
> >>>>>>>>>>>> Hi All,
> >>>>>>>>>>>>
> >>>>>>>>>>>> I have below log42 xml in classes folder and I am on log4j2 .
> >>>> This
> >>>>>>>>>>> setting
> >>>>>>>>>>>> does not log exception and it just logs1 line exception.
> >>>>>>>>>>>>
> >>>>>>>>>>>> How do I make log4j2 to log complete exception trace in mysite
> >>>> log ?
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>> <?xml version="1.0" encoding="UTF-8"?>
> >>>>>>>>>>>> <!--
> >>>>>>>>>>>> To change this template, choose Tools | Templates
> >>>>>>>>>>>> and open the template in the editor.
> >>>>>>>>>>>> -->
> >>>>>>>>>>>> <configuration>
> >>>>>>>>>>>> <Properties>
> >>>>>>>>>>>>     <Property name="log-path">C:/logs/</Property>
> >>>>>>>>>>>> <!--       <Property
> >>>>>>> name="log-path">/home/mydrive/logs/</Property>-->
> >>>>>>>>>>>> </Properties>
> >>>>>>>>>>>> <Appenders>
> >>>>>>>>>>>>    <RollingFile name="RollingFile"
> >>>>>>> fileName="${log-path}/mysite.log"
> >>>>>>>>>>>>
> >>>>>>>>>>>> filePattern="${log-path}/indianads-%d{yyyy-MM-dd}-%i.log">
> >>>>>>>>>>>>        <PatternLayout>
> >>>>>>>>>>>>            <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}:
> >>>>>>>>>>>> %m%ex%n</pattern>
> >>>>>>>>>>>>        </PatternLayout>
> >>>>>>>>>>>>        <Policies>
> >>>>>>>>>>>>            <SizeBasedTriggeringPolicy size="1 MB"/>
> >>>>>>>>>>>>        </Policies>
> >>>>>>>>>>>>        <DefaultRolloverStrategy max="24"/>
> >>>>>>>>>>>>    </RollingFile>
> >>>>>>>>>>>> </Appenders>
> >>>>>>>>>>>> <Loggers>
> >>>>>>>>>>>>    <Logger name="root" level="debug" additivity="false">
> >>>>>>>>>>>>        <appender-ref ref="RollingFile" level="All"/>
> >>>>>>>>>>>>    </Logger>
> >>>>>>>>>>>>    <Root level="All" additivity="false">
> >>>>>>>>>>>>        <AppenderRef ref="RollingFile"/>
> >>>>>>>>>>>>    </Root>
> >>>>>>>>>>>> </Loggers>
> >>>>>>>>>>>> </configuration>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>> ---------------------------------------------------------------------
> >>>>>>>>>>> To unsubscribe, e-mail:
> >>>> log4j-user-unsubscribe@logging.apache.org <javascript:;>
> >>>>>>> <javascript:_e(%7B%7D,'cvml','
> >>>> log4j-user-unsubscribe@logging.apache.org <javascript:;>');>
> >>>>>>>>>>> For additional commands, e-mail:
> >>>> log4j-user-help@logging.apache.org <javascript:;>
> >>>>>>> <javascript:_e(%7B%7D,'cvml','log4j-user-help@logging.apache.org
> <javascript:;>');>
> >>>>>>>>>
> >>>>>>>
> >>>>>>>
> ---------------------------------------------------------------------
> >>>>>>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> <javascript:;>
> >>>>>>> <javascript:_e(%7B%7D,'cvml','
> >>>> log4j-user-unsubscribe@logging.apache.org <javascript:;>');>
> >>>>>>> For additional commands, e-mail:
> log4j-user-help@logging.apache.org <javascript:;>
> >>>>>>> <javascript:_e(%7B%7D,'cvml','log4j-user-help@logging.apache.org
> <javascript:;>');>
> >>>>>>>
> >>>>>>>
> >>>>>>
> >>>>
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> <javascript:;>
> >>>> For additional commands, e-mail: log4j-user-help@logging.apache.org
> <javascript:;>
> >>>>
> >>>>
> >>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> <javascript:;>
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> <javascript:;>
>
>

Re: Logging complete exception trace.

Posted by Ralph Goers <ra...@dslextreme.com>.
I will try to look at it later this evening when I get home from work.

Ralph

> On Oct 6, 2015, at 10:02 AM, Kiran Badi <ad...@aayushs.com> wrote:
> 
> Hi,
> 
> I realised the I had zipped all project files and it was not containing the
> war file
> 
> I have now copied the war file to this shared drive,
> 
> https://drive.google.com/folderview?id=0B-D3EnvFXkj7OTV2a2t2a1I1dk0&usp=sharing
> 
> Please see if someone can take a look and tell me as what I am doing wrong.
> 
> -kiran
> 
> On Mon, Oct 5, 2015 at 7:55 PM, Kiran Badi <ad...@aayushs.com> wrote:
> 
>> Hi All,
>> 
>> Here is the link for the war file which I have created.
>> 
>> I am on log4j2 2.3 version, tomcat 8.0.15 and JDK 1.7. Example is given as
>> close to the issue as what I have in my application.
>> 
>> I have not set the mysql driver so that I get exception whenever I try to
>> connect to db.
>> 
>> 
>> https://drive.google.com/a/aayushs.com/folderview?id=0B-D3EnvFXkj7OTV2a2t2a1I1dk0&usp=sharing
>> 
>> Please let me know as how do I fix this issue.
>> 
>> - Kiran Badi
>> 
>> 
>> On Mon, Sep 21, 2015 at 8:34 AM, Kiran Badi <ad...@aayushs.com> wrote:
>> 
>>> Ok let me build the sample war file for it and see if I can reproduce it
>>> outside of my app.
>>> 
>>> Thanks for hint.
>>> 
>>> 
>>> On Monday, September 21, 2015, Ralph Goers <ra...@dslextreme.com>
>>> wrote:
>>> 
>>>> Can you provide a sample app that demonstrates this? We have a lot of
>>>> tests that don't exhibit this behavior so we really need something not we
>>>> can debug.
>>>> 
>>>> Sent from my iPad
>>>> 
>>>>> On Sep 21, 2015, at 5:11 AM, Kiran Badi <ad...@aayushs.com> wrote:
>>>>> 
>>>>> Hi All
>>>>> 
>>>>> How do I debug this issue now.
>>>>> 
>>>>> Appreciate the help since I have log4j2 at many places. So making a
>>>> change
>>>>> now to logging framework will consume lot of time and I seriously do
>>>> not
>>>>> have luxury of it.
>>>>> 
>>>>> 
>>>>> 
>>>>>> On Saturday, September 19, 2015, Kiran Badi <ad...@aayushs.com>
>>>> wrote:
>>>>>> 
>>>>>> Ok I did the change to the pattern and now my pattern looks like,
>>>>>> 
>>>>>> <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{2}: %m%xEx%n</pattern>
>>>>>> 
>>>>>> 19/Sep/2015 09:29:13,975- mypackage.myclass: Got the DAO
>>>> ExceptionError
>>>>>> inserting data to db. Column count doesn't match value count at row 1
>>>>>> 
>>>>>> No luck :)
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> On Fri, Sep 18, 2015 at 8:40 PM, Remko Popma <remko.popma@gmail.com
>>>>>> <javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com');>> wrote:
>>>>>> 
>>>>>>> Sorry, I made a mistake: %t prints out the Thread. Please replace
>>>> %tEx
>>>>>>> with %xEx. Can you show the output of that?
>>>>>>> 
>>>>>>> Also, what version of log4j are you using? 2.3?
>>>>>>> 
>>>>>>> Sent from my iPhone
>>>>>>> 
>>>>>>>> On 2015/09/18, at 23:27, Kiran Badi <admin@aayushs.com
>>>>>>> <javascript:_e(%7B%7D,'cvml','admin@aayushs.com');>> wrote:
>>>>>>>> 
>>>>>>>> Ok here is the pattern changed  I tried
>>>>>>>> 
>>>>>>>> <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}: %m%tEx%n</pattern>
>>>>>>>> 
>>>>>>>> After doing this, I got this in logs,
>>>>>>>> 
>>>>>>>> 18/Sep/2015 17:23:05,421- myclass: Got the DAO ExceptionError
>>>> inserting
>>>>>>>> into database. Parameter index out of range (24 > number of
>>>> parameters,
>>>>>>>> which is 23).http-bio-8084-exec-35Ex
>>>>>>>> 
>>>>>>>> 
>>>>>>>> All my classes are giving single line exception message,
>>>>>>>> 
>>>>>>>> How do I debug this issue now ?
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>>> On Fri, Sep 18, 2015 at 2:57 PM, Remko Popma <
>>>> remko.popma@gmail.com
>>>>>>> <javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com');>> wrote:
>>>>>>>>> 
>>>>>>>>> Hmm, your source code looks correct. In your config, you could
>>>> probably
>>>>>>>>> remove the named logger entry.
>>>>>>>>>>>> <Logger name="root" level="debug" additivity="false">
>>>>>>>>>>>>        <appender-ref ref="RollingFile" level="All"/>
>>>>>>>>>>>>    </Logger>
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> The <Root> alone is sufficient I think.
>>>>>>>>> But this won't solve the issue...
>>>>>>>>> 
>>>>>>>>> Do you see this behavior everywhere or only in some places?
>>>>>>>>> If you replace %ex in your pattern with %tEx, location info will be
>>>>>>> added
>>>>>>>>> to the output. This may help pinpoint the code that generates the
>>>> log
>>>>>>> entry
>>>>>>>>> so you can double check it...
>>>>>>>>> 
>>>>>>>>> Sorry I don't have a better answer.
>>>>>>>>> 
>>>>>>>>> Remko
>>>>>>>>> 
>>>>>>>>> Sent from my iPhone
>>>>>>>>> 
>>>>>>>>>> On 2015/09/18, at 20:05, Kiran Badi <admin@aayushs.com
>>>>>>> <javascript:_e(%7B%7D,'cvml','admin@aayushs.com');>> wrote:
>>>>>>>>>> 
>>>>>>>>>> Thanks Remko for reply, I think that's how I do it.
>>>>>>>>>> 
>>>>>>>>>> Please see below the way I use it. I am on log4j2 and I have
>>>>>>> log4j-api,
>>>>>>>>>> log4j-core and log4j-web jars in the lib directory of my web app.
>>>>>>>>>> 
>>>>>>>>>> I import these 2 packages
>>>>>>>>>> import org.apache.logging.log4j.LogManager;
>>>>>>>>>> import org.apache.logging.log4j.Logger;
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> Create a static instance
>>>>>>>>>> 
>>>>>>>>>> static final Logger log =
>>>>>>> LogManager.getLogger(myclass.class.getName());
>>>>>>>>>> 
>>>>>>>>>> then do use it in class file
>>>>>>>>>> 
>>>>>>>>>>               catch (Exception ex) {
>>>>>>>>>>                      log.error("Got the exception", ex);
>>>>>>>>>>                 }
>>>>>>>>>> 
>>>>>>>>>> I was under impression that this should log the complete trace,
>>>> but
>>>>>>> its
>>>>>>>>> not.
>>>>>>>>>> 
>>>>>>>>>> Any ideas as what I am missing ?
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>>> On Fri, Sep 18, 2015 at 1:49 PM, Remko Popma <
>>>> remko.popma@gmail.com
>>>>>>> <javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com');>>
>>>>>>>>> wrote:
>>>>>>>>>>> 
>>>>>>>>>>> In your application,
>>>>>>>>>>> do not use logger.error(exception);
>>>>>>>>>>> but use logger.error("some message", exception); instead.
>>>>>>>>>>> 
>>>>>>>>>>> The first form will take the exception object as an object and
>>>> calls
>>>>>>>>>>> toString() on it, which is not what you want.
>>>>>>>>>>> 
>>>>>>>>>>> Remko
>>>>>>>>>>> 
>>>>>>>>>>> Sent from my iPhone
>>>>>>>>>>> 
>>>>>>>>>>>> On 2015/09/18, at 18:00, Kiran Badi <admin@aayushs.com
>>>>>>> <javascript:_e(%7B%7D,'cvml','admin@aayushs.com');>> wrote:
>>>>>>>>>>>> 
>>>>>>>>>>>> Hi All,
>>>>>>>>>>>> 
>>>>>>>>>>>> I have below log42 xml in classes folder and I am on log4j2 .
>>>> This
>>>>>>>>>>> setting
>>>>>>>>>>>> does not log exception and it just logs1 line exception.
>>>>>>>>>>>> 
>>>>>>>>>>>> How do I make log4j2 to log complete exception trace in mysite
>>>> log ?
>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>>>>>>>>> <!--
>>>>>>>>>>>> To change this template, choose Tools | Templates
>>>>>>>>>>>> and open the template in the editor.
>>>>>>>>>>>> -->
>>>>>>>>>>>> <configuration>
>>>>>>>>>>>> <Properties>
>>>>>>>>>>>>     <Property name="log-path">C:/logs/</Property>
>>>>>>>>>>>> <!--       <Property
>>>>>>> name="log-path">/home/mydrive/logs/</Property>-->
>>>>>>>>>>>> </Properties>
>>>>>>>>>>>> <Appenders>
>>>>>>>>>>>>    <RollingFile name="RollingFile"
>>>>>>> fileName="${log-path}/mysite.log"
>>>>>>>>>>>> 
>>>>>>>>>>>> filePattern="${log-path}/indianads-%d{yyyy-MM-dd}-%i.log">
>>>>>>>>>>>>        <PatternLayout>
>>>>>>>>>>>>            <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}:
>>>>>>>>>>>> %m%ex%n</pattern>
>>>>>>>>>>>>        </PatternLayout>
>>>>>>>>>>>>        <Policies>
>>>>>>>>>>>>            <SizeBasedTriggeringPolicy size="1 MB"/>
>>>>>>>>>>>>        </Policies>
>>>>>>>>>>>>        <DefaultRolloverStrategy max="24"/>
>>>>>>>>>>>>    </RollingFile>
>>>>>>>>>>>> </Appenders>
>>>>>>>>>>>> <Loggers>
>>>>>>>>>>>>    <Logger name="root" level="debug" additivity="false">
>>>>>>>>>>>>        <appender-ref ref="RollingFile" level="All"/>
>>>>>>>>>>>>    </Logger>
>>>>>>>>>>>>    <Root level="All" additivity="false">
>>>>>>>>>>>>        <AppenderRef ref="RollingFile"/>
>>>>>>>>>>>>    </Root>
>>>>>>>>>>>> </Loggers>
>>>>>>>>>>>> </configuration>
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>> ---------------------------------------------------------------------
>>>>>>>>>>> To unsubscribe, e-mail:
>>>> log4j-user-unsubscribe@logging.apache.org
>>>>>>> <javascript:_e(%7B%7D,'cvml','
>>>> log4j-user-unsubscribe@logging.apache.org');>
>>>>>>>>>>> For additional commands, e-mail:
>>>> log4j-user-help@logging.apache.org
>>>>>>> <javascript:_e(%7B%7D,'cvml','log4j-user-help@logging.apache.org');>
>>>>>>>>> 
>>>>>>> 
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>>>>>>> <javascript:_e(%7B%7D,'cvml','
>>>> log4j-user-unsubscribe@logging.apache.org');>
>>>>>>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>>>>>>> <javascript:_e(%7B%7D,'cvml','log4j-user-help@logging.apache.org');>
>>>>>>> 
>>>>>>> 
>>>>>> 
>>>> 
>>>> 
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>>>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>>>> 
>>>> 
>> 



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Logging complete exception trace.

Posted by Kiran Badi <ad...@aayushs.com>.
Hi,

I realised the I had zipped all project files and it was not containing the
war file

I have now copied the war file to this shared drive,

https://drive.google.com/folderview?id=0B-D3EnvFXkj7OTV2a2t2a1I1dk0&usp=sharing

Please see if someone can take a look and tell me as what I am doing wrong.

-kiran

On Mon, Oct 5, 2015 at 7:55 PM, Kiran Badi <ad...@aayushs.com> wrote:

> Hi All,
>
> Here is the link for the war file which I have created.
>
> I am on log4j2 2.3 version, tomcat 8.0.15 and JDK 1.7. Example is given as
> close to the issue as what I have in my application.
>
> I have not set the mysql driver so that I get exception whenever I try to
> connect to db.
>
>
> https://drive.google.com/a/aayushs.com/folderview?id=0B-D3EnvFXkj7OTV2a2t2a1I1dk0&usp=sharing
>
> Please let me know as how do I fix this issue.
>
> - Kiran Badi
>
>
> On Mon, Sep 21, 2015 at 8:34 AM, Kiran Badi <ad...@aayushs.com> wrote:
>
>> Ok let me build the sample war file for it and see if I can reproduce it
>> outside of my app.
>>
>> Thanks for hint.
>>
>>
>> On Monday, September 21, 2015, Ralph Goers <ra...@dslextreme.com>
>> wrote:
>>
>>> Can you provide a sample app that demonstrates this? We have a lot of
>>> tests that don't exhibit this behavior so we really need something not we
>>> can debug.
>>>
>>> Sent from my iPad
>>>
>>> > On Sep 21, 2015, at 5:11 AM, Kiran Badi <ad...@aayushs.com> wrote:
>>> >
>>> > Hi All
>>> >
>>> > How do I debug this issue now.
>>> >
>>> > Appreciate the help since I have log4j2 at many places. So making a
>>> change
>>> > now to logging framework will consume lot of time and I seriously do
>>> not
>>> > have luxury of it.
>>> >
>>> >
>>> >
>>> >> On Saturday, September 19, 2015, Kiran Badi <ad...@aayushs.com>
>>> wrote:
>>> >>
>>> >> Ok I did the change to the pattern and now my pattern looks like,
>>> >>
>>> >> <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{2}: %m%xEx%n</pattern>
>>> >>
>>> >> 19/Sep/2015 09:29:13,975- mypackage.myclass: Got the DAO
>>> ExceptionError
>>> >> inserting data to db. Column count doesn't match value count at row 1
>>> >>
>>> >> No luck :)
>>> >>
>>> >>
>>> >>
>>> >>
>>> >> On Fri, Sep 18, 2015 at 8:40 PM, Remko Popma <remko.popma@gmail.com
>>> >> <javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com');>> wrote:
>>> >>
>>> >>> Sorry, I made a mistake: %t prints out the Thread. Please replace
>>> %tEx
>>> >>> with %xEx. Can you show the output of that?
>>> >>>
>>> >>> Also, what version of log4j are you using? 2.3?
>>> >>>
>>> >>> Sent from my iPhone
>>> >>>
>>> >>>> On 2015/09/18, at 23:27, Kiran Badi <admin@aayushs.com
>>> >>> <javascript:_e(%7B%7D,'cvml','admin@aayushs.com');>> wrote:
>>> >>>>
>>> >>>> Ok here is the pattern changed  I tried
>>> >>>>
>>> >>>> <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}: %m%tEx%n</pattern>
>>> >>>>
>>> >>>> After doing this, I got this in logs,
>>> >>>>
>>> >>>> 18/Sep/2015 17:23:05,421- myclass: Got the DAO ExceptionError
>>> inserting
>>> >>>> into database. Parameter index out of range (24 > number of
>>> parameters,
>>> >>>> which is 23).http-bio-8084-exec-35Ex
>>> >>>>
>>> >>>>
>>> >>>> All my classes are giving single line exception message,
>>> >>>>
>>> >>>> How do I debug this issue now ?
>>> >>>>
>>> >>>>
>>> >>>>
>>> >>>>
>>> >>>>
>>> >>>>> On Fri, Sep 18, 2015 at 2:57 PM, Remko Popma <
>>> remko.popma@gmail.com
>>> >>> <javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com');>> wrote:
>>> >>>>>
>>> >>>>> Hmm, your source code looks correct. In your config, you could
>>> probably
>>> >>>>> remove the named logger entry.
>>> >>>>>>>> <Logger name="root" level="debug" additivity="false">
>>> >>>>>>>>         <appender-ref ref="RollingFile" level="All"/>
>>> >>>>>>>>     </Logger>
>>> >>>>>
>>> >>>>>
>>> >>>>> The <Root> alone is sufficient I think.
>>> >>>>> But this won't solve the issue...
>>> >>>>>
>>> >>>>> Do you see this behavior everywhere or only in some places?
>>> >>>>> If you replace %ex in your pattern with %tEx, location info will be
>>> >>> added
>>> >>>>> to the output. This may help pinpoint the code that generates the
>>> log
>>> >>> entry
>>> >>>>> so you can double check it...
>>> >>>>>
>>> >>>>> Sorry I don't have a better answer.
>>> >>>>>
>>> >>>>> Remko
>>> >>>>>
>>> >>>>> Sent from my iPhone
>>> >>>>>
>>> >>>>>> On 2015/09/18, at 20:05, Kiran Badi <admin@aayushs.com
>>> >>> <javascript:_e(%7B%7D,'cvml','admin@aayushs.com');>> wrote:
>>> >>>>>>
>>> >>>>>> Thanks Remko for reply, I think that's how I do it.
>>> >>>>>>
>>> >>>>>> Please see below the way I use it. I am on log4j2 and I have
>>> >>> log4j-api,
>>> >>>>>> log4j-core and log4j-web jars in the lib directory of my web app.
>>> >>>>>>
>>> >>>>>> I import these 2 packages
>>> >>>>>> import org.apache.logging.log4j.LogManager;
>>> >>>>>> import org.apache.logging.log4j.Logger;
>>> >>>>>>
>>> >>>>>>
>>> >>>>>> Create a static instance
>>> >>>>>>
>>> >>>>>> static final Logger log =
>>> >>> LogManager.getLogger(myclass.class.getName());
>>> >>>>>>
>>> >>>>>> then do use it in class file
>>> >>>>>>
>>> >>>>>>                catch (Exception ex) {
>>> >>>>>>                       log.error("Got the exception", ex);
>>> >>>>>>                  }
>>> >>>>>>
>>> >>>>>> I was under impression that this should log the complete trace,
>>> but
>>> >>> its
>>> >>>>> not.
>>> >>>>>>
>>> >>>>>> Any ideas as what I am missing ?
>>> >>>>>>
>>> >>>>>>
>>> >>>>>>
>>> >>>>>>
>>> >>>>>>> On Fri, Sep 18, 2015 at 1:49 PM, Remko Popma <
>>> remko.popma@gmail.com
>>> >>> <javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com');>>
>>> >>>>> wrote:
>>> >>>>>>>
>>> >>>>>>> In your application,
>>> >>>>>>> do not use logger.error(exception);
>>> >>>>>>> but use logger.error("some message", exception); instead.
>>> >>>>>>>
>>> >>>>>>> The first form will take the exception object as an object and
>>> calls
>>> >>>>>>> toString() on it, which is not what you want.
>>> >>>>>>>
>>> >>>>>>> Remko
>>> >>>>>>>
>>> >>>>>>> Sent from my iPhone
>>> >>>>>>>
>>> >>>>>>>> On 2015/09/18, at 18:00, Kiran Badi <admin@aayushs.com
>>> >>> <javascript:_e(%7B%7D,'cvml','admin@aayushs.com');>> wrote:
>>> >>>>>>>>
>>> >>>>>>>> Hi All,
>>> >>>>>>>>
>>> >>>>>>>> I have below log42 xml in classes folder and I am on log4j2 .
>>> This
>>> >>>>>>> setting
>>> >>>>>>>> does not log exception and it just logs1 line exception.
>>> >>>>>>>>
>>> >>>>>>>> How do I make log4j2 to log complete exception trace in mysite
>>> log ?
>>> >>>>>>>>
>>> >>>>>>>>
>>> >>>>>>>>
>>> >>>>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>> >>>>>>>> <!--
>>> >>>>>>>> To change this template, choose Tools | Templates
>>> >>>>>>>> and open the template in the editor.
>>> >>>>>>>> -->
>>> >>>>>>>> <configuration>
>>> >>>>>>>> <Properties>
>>> >>>>>>>>      <Property name="log-path">C:/logs/</Property>
>>> >>>>>>>> <!--       <Property
>>> >>> name="log-path">/home/mydrive/logs/</Property>-->
>>> >>>>>>>> </Properties>
>>> >>>>>>>> <Appenders>
>>> >>>>>>>>     <RollingFile name="RollingFile"
>>> >>> fileName="${log-path}/mysite.log"
>>> >>>>>>>>
>>> >>>>>>>> filePattern="${log-path}/indianads-%d{yyyy-MM-dd}-%i.log">
>>> >>>>>>>>         <PatternLayout>
>>> >>>>>>>>             <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}:
>>> >>>>>>>> %m%ex%n</pattern>
>>> >>>>>>>>         </PatternLayout>
>>> >>>>>>>>         <Policies>
>>> >>>>>>>>             <SizeBasedTriggeringPolicy size="1 MB"/>
>>> >>>>>>>>         </Policies>
>>> >>>>>>>>         <DefaultRolloverStrategy max="24"/>
>>> >>>>>>>>     </RollingFile>
>>> >>>>>>>> </Appenders>
>>> >>>>>>>> <Loggers>
>>> >>>>>>>>     <Logger name="root" level="debug" additivity="false">
>>> >>>>>>>>         <appender-ref ref="RollingFile" level="All"/>
>>> >>>>>>>>     </Logger>
>>> >>>>>>>>     <Root level="All" additivity="false">
>>> >>>>>>>>         <AppenderRef ref="RollingFile"/>
>>> >>>>>>>>     </Root>
>>> >>>>>>>> </Loggers>
>>> >>>>>>>> </configuration>
>>> >>>>>>>
>>> >>>>>>>
>>> ---------------------------------------------------------------------
>>> >>>>>>> To unsubscribe, e-mail:
>>> log4j-user-unsubscribe@logging.apache.org
>>> >>> <javascript:_e(%7B%7D,'cvml','
>>> log4j-user-unsubscribe@logging.apache.org');>
>>> >>>>>>> For additional commands, e-mail:
>>> log4j-user-help@logging.apache.org
>>> >>> <javascript:_e(%7B%7D,'cvml','log4j-user-help@logging.apache.org');>
>>> >>>>>
>>> >>>
>>> >>> ---------------------------------------------------------------------
>>> >>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>>> >>> <javascript:_e(%7B%7D,'cvml','
>>> log4j-user-unsubscribe@logging.apache.org');>
>>> >>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>>> >>> <javascript:_e(%7B%7D,'cvml','log4j-user-help@logging.apache.org');>
>>> >>>
>>> >>>
>>> >>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>>>
>>>
>

Re: Logging complete exception trace.

Posted by Kiran Badi <ad...@aayushs.com>.
Hi All,

Here is the link for the war file which I have created.

I am on log4j2 2.3 version, tomcat 8.0.15 and JDK 1.7. Example is given as
close to the issue as what I have in my application.

I have not set the mysql driver so that I get exception whenever I try to
connect to db.

https://drive.google.com/a/aayushs.com/folderview?id=0B-D3EnvFXkj7OTV2a2t2a1I1dk0&usp=sharing

Please let me know as how do I fix this issue.

- Kiran Badi


On Mon, Sep 21, 2015 at 8:34 AM, Kiran Badi <ad...@aayushs.com> wrote:

> Ok let me build the sample war file for it and see if I can reproduce it
> outside of my app.
>
> Thanks for hint.
>
>
> On Monday, September 21, 2015, Ralph Goers <ra...@dslextreme.com>
> wrote:
>
>> Can you provide a sample app that demonstrates this? We have a lot of
>> tests that don't exhibit this behavior so we really need something not we
>> can debug.
>>
>> Sent from my iPad
>>
>> > On Sep 21, 2015, at 5:11 AM, Kiran Badi <ad...@aayushs.com> wrote:
>> >
>> > Hi All
>> >
>> > How do I debug this issue now.
>> >
>> > Appreciate the help since I have log4j2 at many places. So making a
>> change
>> > now to logging framework will consume lot of time and I seriously do not
>> > have luxury of it.
>> >
>> >
>> >
>> >> On Saturday, September 19, 2015, Kiran Badi <ad...@aayushs.com> wrote:
>> >>
>> >> Ok I did the change to the pattern and now my pattern looks like,
>> >>
>> >> <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{2}: %m%xEx%n</pattern>
>> >>
>> >> 19/Sep/2015 09:29:13,975- mypackage.myclass: Got the DAO ExceptionError
>> >> inserting data to db. Column count doesn't match value count at row 1
>> >>
>> >> No luck :)
>> >>
>> >>
>> >>
>> >>
>> >> On Fri, Sep 18, 2015 at 8:40 PM, Remko Popma <remko.popma@gmail.com
>> >> <javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com');>> wrote:
>> >>
>> >>> Sorry, I made a mistake: %t prints out the Thread. Please replace %tEx
>> >>> with %xEx. Can you show the output of that?
>> >>>
>> >>> Also, what version of log4j are you using? 2.3?
>> >>>
>> >>> Sent from my iPhone
>> >>>
>> >>>> On 2015/09/18, at 23:27, Kiran Badi <admin@aayushs.com
>> >>> <javascript:_e(%7B%7D,'cvml','admin@aayushs.com');>> wrote:
>> >>>>
>> >>>> Ok here is the pattern changed  I tried
>> >>>>
>> >>>> <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}: %m%tEx%n</pattern>
>> >>>>
>> >>>> After doing this, I got this in logs,
>> >>>>
>> >>>> 18/Sep/2015 17:23:05,421- myclass: Got the DAO ExceptionError
>> inserting
>> >>>> into database. Parameter index out of range (24 > number of
>> parameters,
>> >>>> which is 23).http-bio-8084-exec-35Ex
>> >>>>
>> >>>>
>> >>>> All my classes are giving single line exception message,
>> >>>>
>> >>>> How do I debug this issue now ?
>> >>>>
>> >>>>
>> >>>>
>> >>>>
>> >>>>
>> >>>>> On Fri, Sep 18, 2015 at 2:57 PM, Remko Popma <remko.popma@gmail.com
>> >>> <javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com');>> wrote:
>> >>>>>
>> >>>>> Hmm, your source code looks correct. In your config, you could
>> probably
>> >>>>> remove the named logger entry.
>> >>>>>>>> <Logger name="root" level="debug" additivity="false">
>> >>>>>>>>         <appender-ref ref="RollingFile" level="All"/>
>> >>>>>>>>     </Logger>
>> >>>>>
>> >>>>>
>> >>>>> The <Root> alone is sufficient I think.
>> >>>>> But this won't solve the issue...
>> >>>>>
>> >>>>> Do you see this behavior everywhere or only in some places?
>> >>>>> If you replace %ex in your pattern with %tEx, location info will be
>> >>> added
>> >>>>> to the output. This may help pinpoint the code that generates the
>> log
>> >>> entry
>> >>>>> so you can double check it...
>> >>>>>
>> >>>>> Sorry I don't have a better answer.
>> >>>>>
>> >>>>> Remko
>> >>>>>
>> >>>>> Sent from my iPhone
>> >>>>>
>> >>>>>> On 2015/09/18, at 20:05, Kiran Badi <admin@aayushs.com
>> >>> <javascript:_e(%7B%7D,'cvml','admin@aayushs.com');>> wrote:
>> >>>>>>
>> >>>>>> Thanks Remko for reply, I think that's how I do it.
>> >>>>>>
>> >>>>>> Please see below the way I use it. I am on log4j2 and I have
>> >>> log4j-api,
>> >>>>>> log4j-core and log4j-web jars in the lib directory of my web app.
>> >>>>>>
>> >>>>>> I import these 2 packages
>> >>>>>> import org.apache.logging.log4j.LogManager;
>> >>>>>> import org.apache.logging.log4j.Logger;
>> >>>>>>
>> >>>>>>
>> >>>>>> Create a static instance
>> >>>>>>
>> >>>>>> static final Logger log =
>> >>> LogManager.getLogger(myclass.class.getName());
>> >>>>>>
>> >>>>>> then do use it in class file
>> >>>>>>
>> >>>>>>                catch (Exception ex) {
>> >>>>>>                       log.error("Got the exception", ex);
>> >>>>>>                  }
>> >>>>>>
>> >>>>>> I was under impression that this should log the complete trace, but
>> >>> its
>> >>>>> not.
>> >>>>>>
>> >>>>>> Any ideas as what I am missing ?
>> >>>>>>
>> >>>>>>
>> >>>>>>
>> >>>>>>
>> >>>>>>> On Fri, Sep 18, 2015 at 1:49 PM, Remko Popma <
>> remko.popma@gmail.com
>> >>> <javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com');>>
>> >>>>> wrote:
>> >>>>>>>
>> >>>>>>> In your application,
>> >>>>>>> do not use logger.error(exception);
>> >>>>>>> but use logger.error("some message", exception); instead.
>> >>>>>>>
>> >>>>>>> The first form will take the exception object as an object and
>> calls
>> >>>>>>> toString() on it, which is not what you want.
>> >>>>>>>
>> >>>>>>> Remko
>> >>>>>>>
>> >>>>>>> Sent from my iPhone
>> >>>>>>>
>> >>>>>>>> On 2015/09/18, at 18:00, Kiran Badi <admin@aayushs.com
>> >>> <javascript:_e(%7B%7D,'cvml','admin@aayushs.com');>> wrote:
>> >>>>>>>>
>> >>>>>>>> Hi All,
>> >>>>>>>>
>> >>>>>>>> I have below log42 xml in classes folder and I am on log4j2 .
>> This
>> >>>>>>> setting
>> >>>>>>>> does not log exception and it just logs1 line exception.
>> >>>>>>>>
>> >>>>>>>> How do I make log4j2 to log complete exception trace in mysite
>> log ?
>> >>>>>>>>
>> >>>>>>>>
>> >>>>>>>>
>> >>>>>>>> <?xml version="1.0" encoding="UTF-8"?>
>> >>>>>>>> <!--
>> >>>>>>>> To change this template, choose Tools | Templates
>> >>>>>>>> and open the template in the editor.
>> >>>>>>>> -->
>> >>>>>>>> <configuration>
>> >>>>>>>> <Properties>
>> >>>>>>>>      <Property name="log-path">C:/logs/</Property>
>> >>>>>>>> <!--       <Property
>> >>> name="log-path">/home/mydrive/logs/</Property>-->
>> >>>>>>>> </Properties>
>> >>>>>>>> <Appenders>
>> >>>>>>>>     <RollingFile name="RollingFile"
>> >>> fileName="${log-path}/mysite.log"
>> >>>>>>>>
>> >>>>>>>> filePattern="${log-path}/indianads-%d{yyyy-MM-dd}-%i.log">
>> >>>>>>>>         <PatternLayout>
>> >>>>>>>>             <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}:
>> >>>>>>>> %m%ex%n</pattern>
>> >>>>>>>>         </PatternLayout>
>> >>>>>>>>         <Policies>
>> >>>>>>>>             <SizeBasedTriggeringPolicy size="1 MB"/>
>> >>>>>>>>         </Policies>
>> >>>>>>>>         <DefaultRolloverStrategy max="24"/>
>> >>>>>>>>     </RollingFile>
>> >>>>>>>> </Appenders>
>> >>>>>>>> <Loggers>
>> >>>>>>>>     <Logger name="root" level="debug" additivity="false">
>> >>>>>>>>         <appender-ref ref="RollingFile" level="All"/>
>> >>>>>>>>     </Logger>
>> >>>>>>>>     <Root level="All" additivity="false">
>> >>>>>>>>         <AppenderRef ref="RollingFile"/>
>> >>>>>>>>     </Root>
>> >>>>>>>> </Loggers>
>> >>>>>>>> </configuration>
>> >>>>>>>
>> >>>>>>>
>> ---------------------------------------------------------------------
>> >>>>>>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> >>> <javascript:_e(%7B%7D,'cvml','
>> log4j-user-unsubscribe@logging.apache.org');>
>> >>>>>>> For additional commands, e-mail:
>> log4j-user-help@logging.apache.org
>> >>> <javascript:_e(%7B%7D,'cvml','log4j-user-help@logging.apache.org');>
>> >>>>>
>> >>>
>> >>> ---------------------------------------------------------------------
>> >>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> >>> <javascript:_e(%7B%7D,'cvml','
>> log4j-user-unsubscribe@logging.apache.org');>
>> >>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>> >>> <javascript:_e(%7B%7D,'cvml','log4j-user-help@logging.apache.org');>
>> >>>
>> >>>
>> >>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>>
>>

Re: Logging complete exception trace.

Posted by Kiran Badi <ad...@aayushs.com>.
Ok let me build the sample war file for it and see if I can reproduce it
outside of my app.

Thanks for hint.

On Monday, September 21, 2015, Ralph Goers <ra...@dslextreme.com>
wrote:

> Can you provide a sample app that demonstrates this? We have a lot of
> tests that don't exhibit this behavior so we really need something not we
> can debug.
>
> Sent from my iPad
>
> > On Sep 21, 2015, at 5:11 AM, Kiran Badi <admin@aayushs.com
> <javascript:;>> wrote:
> >
> > Hi All
> >
> > How do I debug this issue now.
> >
> > Appreciate the help since I have log4j2 at many places. So making a
> change
> > now to logging framework will consume lot of time and I seriously do not
> > have luxury of it.
> >
> >
> >
> >> On Saturday, September 19, 2015, Kiran Badi <admin@aayushs.com
> <javascript:;>> wrote:
> >>
> >> Ok I did the change to the pattern and now my pattern looks like,
> >>
> >> <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{2}: %m%xEx%n</pattern>
> >>
> >> 19/Sep/2015 09:29:13,975- mypackage.myclass: Got the DAO ExceptionError
> >> inserting data to db. Column count doesn't match value count at row 1
> >>
> >> No luck :)
> >>
> >>
> >>
> >>
> >> On Fri, Sep 18, 2015 at 8:40 PM, Remko Popma <remko.popma@gmail.com
> <javascript:;>
> >> <javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com <javascript:;>');>>
> wrote:
> >>
> >>> Sorry, I made a mistake: %t prints out the Thread. Please replace %tEx
> >>> with %xEx. Can you show the output of that?
> >>>
> >>> Also, what version of log4j are you using? 2.3?
> >>>
> >>> Sent from my iPhone
> >>>
> >>>> On 2015/09/18, at 23:27, Kiran Badi <admin@aayushs.com <javascript:;>
> >>> <javascript:_e(%7B%7D,'cvml','admin@aayushs.com <javascript:;>');>>
> wrote:
> >>>>
> >>>> Ok here is the pattern changed  I tried
> >>>>
> >>>> <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}: %m%tEx%n</pattern>
> >>>>
> >>>> After doing this, I got this in logs,
> >>>>
> >>>> 18/Sep/2015 17:23:05,421- myclass: Got the DAO ExceptionError
> inserting
> >>>> into database. Parameter index out of range (24 > number of
> parameters,
> >>>> which is 23).http-bio-8084-exec-35Ex
> >>>>
> >>>>
> >>>> All my classes are giving single line exception message,
> >>>>
> >>>> How do I debug this issue now ?
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>> On Fri, Sep 18, 2015 at 2:57 PM, Remko Popma <remko.popma@gmail.com
> <javascript:;>
> >>> <javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com <javascript:;>');>>
> wrote:
> >>>>>
> >>>>> Hmm, your source code looks correct. In your config, you could
> probably
> >>>>> remove the named logger entry.
> >>>>>>>> <Logger name="root" level="debug" additivity="false">
> >>>>>>>>         <appender-ref ref="RollingFile" level="All"/>
> >>>>>>>>     </Logger>
> >>>>>
> >>>>>
> >>>>> The <Root> alone is sufficient I think.
> >>>>> But this won't solve the issue...
> >>>>>
> >>>>> Do you see this behavior everywhere or only in some places?
> >>>>> If you replace %ex in your pattern with %tEx, location info will be
> >>> added
> >>>>> to the output. This may help pinpoint the code that generates the log
> >>> entry
> >>>>> so you can double check it...
> >>>>>
> >>>>> Sorry I don't have a better answer.
> >>>>>
> >>>>> Remko
> >>>>>
> >>>>> Sent from my iPhone
> >>>>>
> >>>>>> On 2015/09/18, at 20:05, Kiran Badi <admin@aayushs.com
> <javascript:;>
> >>> <javascript:_e(%7B%7D,'cvml','admin@aayushs.com <javascript:;>');>>
> wrote:
> >>>>>>
> >>>>>> Thanks Remko for reply, I think that's how I do it.
> >>>>>>
> >>>>>> Please see below the way I use it. I am on log4j2 and I have
> >>> log4j-api,
> >>>>>> log4j-core and log4j-web jars in the lib directory of my web app.
> >>>>>>
> >>>>>> I import these 2 packages
> >>>>>> import org.apache.logging.log4j.LogManager;
> >>>>>> import org.apache.logging.log4j.Logger;
> >>>>>>
> >>>>>>
> >>>>>> Create a static instance
> >>>>>>
> >>>>>> static final Logger log =
> >>> LogManager.getLogger(myclass.class.getName());
> >>>>>>
> >>>>>> then do use it in class file
> >>>>>>
> >>>>>>                catch (Exception ex) {
> >>>>>>                       log.error("Got the exception", ex);
> >>>>>>                  }
> >>>>>>
> >>>>>> I was under impression that this should log the complete trace, but
> >>> its
> >>>>> not.
> >>>>>>
> >>>>>> Any ideas as what I am missing ?
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>> On Fri, Sep 18, 2015 at 1:49 PM, Remko Popma <
> remko.popma@gmail.com <javascript:;>
> >>> <javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com <javascript:;>
> ');>>
> >>>>> wrote:
> >>>>>>>
> >>>>>>> In your application,
> >>>>>>> do not use logger.error(exception);
> >>>>>>> but use logger.error("some message", exception); instead.
> >>>>>>>
> >>>>>>> The first form will take the exception object as an object and
> calls
> >>>>>>> toString() on it, which is not what you want.
> >>>>>>>
> >>>>>>> Remko
> >>>>>>>
> >>>>>>> Sent from my iPhone
> >>>>>>>
> >>>>>>>> On 2015/09/18, at 18:00, Kiran Badi <admin@aayushs.com
> <javascript:;>
> >>> <javascript:_e(%7B%7D,'cvml','admin@aayushs.com <javascript:;>');>>
> wrote:
> >>>>>>>>
> >>>>>>>> Hi All,
> >>>>>>>>
> >>>>>>>> I have below log42 xml in classes folder and I am on log4j2 . This
> >>>>>>> setting
> >>>>>>>> does not log exception and it just logs1 line exception.
> >>>>>>>>
> >>>>>>>> How do I make log4j2 to log complete exception trace in mysite
> log ?
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> <?xml version="1.0" encoding="UTF-8"?>
> >>>>>>>> <!--
> >>>>>>>> To change this template, choose Tools | Templates
> >>>>>>>> and open the template in the editor.
> >>>>>>>> -->
> >>>>>>>> <configuration>
> >>>>>>>> <Properties>
> >>>>>>>>      <Property name="log-path">C:/logs/</Property>
> >>>>>>>> <!--       <Property
> >>> name="log-path">/home/mydrive/logs/</Property>-->
> >>>>>>>> </Properties>
> >>>>>>>> <Appenders>
> >>>>>>>>     <RollingFile name="RollingFile"
> >>> fileName="${log-path}/mysite.log"
> >>>>>>>>
> >>>>>>>> filePattern="${log-path}/indianads-%d{yyyy-MM-dd}-%i.log">
> >>>>>>>>         <PatternLayout>
> >>>>>>>>             <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}:
> >>>>>>>> %m%ex%n</pattern>
> >>>>>>>>         </PatternLayout>
> >>>>>>>>         <Policies>
> >>>>>>>>             <SizeBasedTriggeringPolicy size="1 MB"/>
> >>>>>>>>         </Policies>
> >>>>>>>>         <DefaultRolloverStrategy max="24"/>
> >>>>>>>>     </RollingFile>
> >>>>>>>> </Appenders>
> >>>>>>>> <Loggers>
> >>>>>>>>     <Logger name="root" level="debug" additivity="false">
> >>>>>>>>         <appender-ref ref="RollingFile" level="All"/>
> >>>>>>>>     </Logger>
> >>>>>>>>     <Root level="All" additivity="false">
> >>>>>>>>         <AppenderRef ref="RollingFile"/>
> >>>>>>>>     </Root>
> >>>>>>>> </Loggers>
> >>>>>>>> </configuration>
> >>>>>>>
> >>>>>>>
> ---------------------------------------------------------------------
> >>>>>>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> <javascript:;>
> >>> <javascript:_e(%7B%7D,'cvml','
> log4j-user-unsubscribe@logging.apache.org <javascript:;>');>
> >>>>>>> For additional commands, e-mail:
> log4j-user-help@logging.apache.org <javascript:;>
> >>> <javascript:_e(%7B%7D,'cvml','log4j-user-help@logging.apache.org
> <javascript:;>');>
> >>>>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> <javascript:;>
> >>> <javascript:_e(%7B%7D,'cvml','
> log4j-user-unsubscribe@logging.apache.org <javascript:;>');>
> >>> For additional commands, e-mail: log4j-user-help@logging.apache.org
> <javascript:;>
> >>> <javascript:_e(%7B%7D,'cvml','log4j-user-help@logging.apache.org
> <javascript:;>');>
> >>>
> >>>
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> <javascript:;>
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> <javascript:;>
>
>

Re: Logging complete exception trace.

Posted by Ralph Goers <ra...@dslextreme.com>.
Can you provide a sample app that demonstrates this? We have a lot of tests that don't exhibit this behavior so we really need something not we can debug.

Sent from my iPad

> On Sep 21, 2015, at 5:11 AM, Kiran Badi <ad...@aayushs.com> wrote:
> 
> Hi All
> 
> How do I debug this issue now.
> 
> Appreciate the help since I have log4j2 at many places. So making a change
> now to logging framework will consume lot of time and I seriously do not
> have luxury of it.
> 
> 
> 
>> On Saturday, September 19, 2015, Kiran Badi <ad...@aayushs.com> wrote:
>> 
>> Ok I did the change to the pattern and now my pattern looks like,
>> 
>> <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{2}: %m%xEx%n</pattern>
>> 
>> 19/Sep/2015 09:29:13,975- mypackage.myclass: Got the DAO ExceptionError
>> inserting data to db. Column count doesn't match value count at row 1
>> 
>> No luck :)
>> 
>> 
>> 
>> 
>> On Fri, Sep 18, 2015 at 8:40 PM, Remko Popma <remko.popma@gmail.com
>> <javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com');>> wrote:
>> 
>>> Sorry, I made a mistake: %t prints out the Thread. Please replace %tEx
>>> with %xEx. Can you show the output of that?
>>> 
>>> Also, what version of log4j are you using? 2.3?
>>> 
>>> Sent from my iPhone
>>> 
>>>> On 2015/09/18, at 23:27, Kiran Badi <admin@aayushs.com
>>> <javascript:_e(%7B%7D,'cvml','admin@aayushs.com');>> wrote:
>>>> 
>>>> Ok here is the pattern changed  I tried
>>>> 
>>>> <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}: %m%tEx%n</pattern>
>>>> 
>>>> After doing this, I got this in logs,
>>>> 
>>>> 18/Sep/2015 17:23:05,421- myclass: Got the DAO ExceptionError inserting
>>>> into database. Parameter index out of range (24 > number of parameters,
>>>> which is 23).http-bio-8084-exec-35Ex
>>>> 
>>>> 
>>>> All my classes are giving single line exception message,
>>>> 
>>>> How do I debug this issue now ?
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>>> On Fri, Sep 18, 2015 at 2:57 PM, Remko Popma <remko.popma@gmail.com
>>> <javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com');>> wrote:
>>>>> 
>>>>> Hmm, your source code looks correct. In your config, you could probably
>>>>> remove the named logger entry.
>>>>>>>> <Logger name="root" level="debug" additivity="false">
>>>>>>>>         <appender-ref ref="RollingFile" level="All"/>
>>>>>>>>     </Logger>
>>>>> 
>>>>> 
>>>>> The <Root> alone is sufficient I think.
>>>>> But this won't solve the issue...
>>>>> 
>>>>> Do you see this behavior everywhere or only in some places?
>>>>> If you replace %ex in your pattern with %tEx, location info will be
>>> added
>>>>> to the output. This may help pinpoint the code that generates the log
>>> entry
>>>>> so you can double check it...
>>>>> 
>>>>> Sorry I don't have a better answer.
>>>>> 
>>>>> Remko
>>>>> 
>>>>> Sent from my iPhone
>>>>> 
>>>>>> On 2015/09/18, at 20:05, Kiran Badi <admin@aayushs.com
>>> <javascript:_e(%7B%7D,'cvml','admin@aayushs.com');>> wrote:
>>>>>> 
>>>>>> Thanks Remko for reply, I think that's how I do it.
>>>>>> 
>>>>>> Please see below the way I use it. I am on log4j2 and I have
>>> log4j-api,
>>>>>> log4j-core and log4j-web jars in the lib directory of my web app.
>>>>>> 
>>>>>> I import these 2 packages
>>>>>> import org.apache.logging.log4j.LogManager;
>>>>>> import org.apache.logging.log4j.Logger;
>>>>>> 
>>>>>> 
>>>>>> Create a static instance
>>>>>> 
>>>>>> static final Logger log =
>>> LogManager.getLogger(myclass.class.getName());
>>>>>> 
>>>>>> then do use it in class file
>>>>>> 
>>>>>>                catch (Exception ex) {
>>>>>>                       log.error("Got the exception", ex);
>>>>>>                  }
>>>>>> 
>>>>>> I was under impression that this should log the complete trace, but
>>> its
>>>>> not.
>>>>>> 
>>>>>> Any ideas as what I am missing ?
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>>> On Fri, Sep 18, 2015 at 1:49 PM, Remko Popma <remko.popma@gmail.com
>>> <javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com');>>
>>>>> wrote:
>>>>>>> 
>>>>>>> In your application,
>>>>>>> do not use logger.error(exception);
>>>>>>> but use logger.error("some message", exception); instead.
>>>>>>> 
>>>>>>> The first form will take the exception object as an object and calls
>>>>>>> toString() on it, which is not what you want.
>>>>>>> 
>>>>>>> Remko
>>>>>>> 
>>>>>>> Sent from my iPhone
>>>>>>> 
>>>>>>>> On 2015/09/18, at 18:00, Kiran Badi <admin@aayushs.com
>>> <javascript:_e(%7B%7D,'cvml','admin@aayushs.com');>> wrote:
>>>>>>>> 
>>>>>>>> Hi All,
>>>>>>>> 
>>>>>>>> I have below log42 xml in classes folder and I am on log4j2 . This
>>>>>>> setting
>>>>>>>> does not log exception and it just logs1 line exception.
>>>>>>>> 
>>>>>>>> How do I make log4j2 to log complete exception trace in mysite log ?
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>>>>> <!--
>>>>>>>> To change this template, choose Tools | Templates
>>>>>>>> and open the template in the editor.
>>>>>>>> -->
>>>>>>>> <configuration>
>>>>>>>> <Properties>
>>>>>>>>      <Property name="log-path">C:/logs/</Property>
>>>>>>>> <!--       <Property
>>> name="log-path">/home/mydrive/logs/</Property>-->
>>>>>>>> </Properties>
>>>>>>>> <Appenders>
>>>>>>>>     <RollingFile name="RollingFile"
>>> fileName="${log-path}/mysite.log"
>>>>>>>> 
>>>>>>>> filePattern="${log-path}/indianads-%d{yyyy-MM-dd}-%i.log">
>>>>>>>>         <PatternLayout>
>>>>>>>>             <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}:
>>>>>>>> %m%ex%n</pattern>
>>>>>>>>         </PatternLayout>
>>>>>>>>         <Policies>
>>>>>>>>             <SizeBasedTriggeringPolicy size="1 MB"/>
>>>>>>>>         </Policies>
>>>>>>>>         <DefaultRolloverStrategy max="24"/>
>>>>>>>>     </RollingFile>
>>>>>>>> </Appenders>
>>>>>>>> <Loggers>
>>>>>>>>     <Logger name="root" level="debug" additivity="false">
>>>>>>>>         <appender-ref ref="RollingFile" level="All"/>
>>>>>>>>     </Logger>
>>>>>>>>     <Root level="All" additivity="false">
>>>>>>>>         <AppenderRef ref="RollingFile"/>
>>>>>>>>     </Root>
>>>>>>>> </Loggers>
>>>>>>>> </configuration>
>>>>>>> 
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>>> <javascript:_e(%7B%7D,'cvml','log4j-user-unsubscribe@logging.apache.org');>
>>>>>>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>>> <javascript:_e(%7B%7D,'cvml','log4j-user-help@logging.apache.org');>
>>>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>>> <javascript:_e(%7B%7D,'cvml','log4j-user-unsubscribe@logging.apache.org');>
>>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>>> <javascript:_e(%7B%7D,'cvml','log4j-user-help@logging.apache.org');>
>>> 
>>> 
>> 


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Logging complete exception trace.

Posted by Kiran Badi <ad...@aayushs.com>.
Hi All

How do I debug this issue now.

Appreciate the help since I have log4j2 at many places. So making a change
now to logging framework will consume lot of time and I seriously do not
have luxury of it.



On Saturday, September 19, 2015, Kiran Badi <ad...@aayushs.com> wrote:

> Ok I did the change to the pattern and now my pattern looks like,
>
>  <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{2}: %m%xEx%n</pattern>
>
> 19/Sep/2015 09:29:13,975- mypackage.myclass: Got the DAO ExceptionError
> inserting data to db. Column count doesn't match value count at row 1
>
> No luck :)
>
>
>
>
> On Fri, Sep 18, 2015 at 8:40 PM, Remko Popma <remko.popma@gmail.com
> <javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com');>> wrote:
>
>> Sorry, I made a mistake: %t prints out the Thread. Please replace %tEx
>> with %xEx. Can you show the output of that?
>>
>> Also, what version of log4j are you using? 2.3?
>>
>> Sent from my iPhone
>>
>> > On 2015/09/18, at 23:27, Kiran Badi <admin@aayushs.com
>> <javascript:_e(%7B%7D,'cvml','admin@aayushs.com');>> wrote:
>> >
>> > Ok here is the pattern changed  I tried
>> >
>> > <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}: %m%tEx%n</pattern>
>> >
>> > After doing this, I got this in logs,
>> >
>> > 18/Sep/2015 17:23:05,421- myclass: Got the DAO ExceptionError inserting
>> > into database. Parameter index out of range (24 > number of parameters,
>> > which is 23).http-bio-8084-exec-35Ex
>> >
>> >
>> > All my classes are giving single line exception message,
>> >
>> > How do I debug this issue now ?
>> >
>> >
>> >
>> >
>> >
>> >> On Fri, Sep 18, 2015 at 2:57 PM, Remko Popma <remko.popma@gmail.com
>> <javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com');>> wrote:
>> >>
>> >> Hmm, your source code looks correct. In your config, you could probably
>> >> remove the named logger entry.
>> >>>>> <Logger name="root" level="debug" additivity="false">
>> >>>>>          <appender-ref ref="RollingFile" level="All"/>
>> >>>>>      </Logger>
>> >>
>> >>
>> >> The <Root> alone is sufficient I think.
>> >> But this won't solve the issue...
>> >>
>> >> Do you see this behavior everywhere or only in some places?
>> >> If you replace %ex in your pattern with %tEx, location info will be
>> added
>> >> to the output. This may help pinpoint the code that generates the log
>> entry
>> >> so you can double check it...
>> >>
>> >> Sorry I don't have a better answer.
>> >>
>> >> Remko
>> >>
>> >> Sent from my iPhone
>> >>
>> >>> On 2015/09/18, at 20:05, Kiran Badi <admin@aayushs.com
>> <javascript:_e(%7B%7D,'cvml','admin@aayushs.com');>> wrote:
>> >>>
>> >>> Thanks Remko for reply, I think that's how I do it.
>> >>>
>> >>> Please see below the way I use it. I am on log4j2 and I have
>> log4j-api,
>> >>> log4j-core and log4j-web jars in the lib directory of my web app.
>> >>>
>> >>> I import these 2 packages
>> >>> import org.apache.logging.log4j.LogManager;
>> >>> import org.apache.logging.log4j.Logger;
>> >>>
>> >>>
>> >>> Create a static instance
>> >>>
>> >>> static final Logger log =
>> LogManager.getLogger(myclass.class.getName());
>> >>>
>> >>> then do use it in class file
>> >>>
>> >>>                 catch (Exception ex) {
>> >>>                        log.error("Got the exception", ex);
>> >>>                   }
>> >>>
>> >>> I was under impression that this should log the complete trace, but
>> its
>> >> not.
>> >>>
>> >>> Any ideas as what I am missing ?
>> >>>
>> >>>
>> >>>
>> >>>
>> >>>> On Fri, Sep 18, 2015 at 1:49 PM, Remko Popma <remko.popma@gmail.com
>> <javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com');>>
>> >> wrote:
>> >>>>
>> >>>> In your application,
>> >>>> do not use logger.error(exception);
>> >>>> but use logger.error("some message", exception); instead.
>> >>>>
>> >>>> The first form will take the exception object as an object and calls
>> >>>> toString() on it, which is not what you want.
>> >>>>
>> >>>> Remko
>> >>>>
>> >>>> Sent from my iPhone
>> >>>>
>> >>>>> On 2015/09/18, at 18:00, Kiran Badi <admin@aayushs.com
>> <javascript:_e(%7B%7D,'cvml','admin@aayushs.com');>> wrote:
>> >>>>>
>> >>>>> Hi All,
>> >>>>>
>> >>>>> I have below log42 xml in classes folder and I am on log4j2 . This
>> >>>> setting
>> >>>>> does not log exception and it just logs1 line exception.
>> >>>>>
>> >>>>> How do I make log4j2 to log complete exception trace in mysite log ?
>> >>>>>
>> >>>>>
>> >>>>>
>> >>>>> <?xml version="1.0" encoding="UTF-8"?>
>> >>>>> <!--
>> >>>>> To change this template, choose Tools | Templates
>> >>>>> and open the template in the editor.
>> >>>>> -->
>> >>>>> <configuration>
>> >>>>>  <Properties>
>> >>>>>       <Property name="log-path">C:/logs/</Property>
>> >>>>> <!--       <Property
>> name="log-path">/home/mydrive/logs/</Property>-->
>> >>>>>  </Properties>
>> >>>>>  <Appenders>
>> >>>>>      <RollingFile name="RollingFile"
>> fileName="${log-path}/mysite.log"
>> >>>>>
>> >>>>> filePattern="${log-path}/indianads-%d{yyyy-MM-dd}-%i.log">
>> >>>>>          <PatternLayout>
>> >>>>>              <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}:
>> >>>>> %m%ex%n</pattern>
>> >>>>>          </PatternLayout>
>> >>>>>          <Policies>
>> >>>>>              <SizeBasedTriggeringPolicy size="1 MB"/>
>> >>>>>          </Policies>
>> >>>>>          <DefaultRolloverStrategy max="24"/>
>> >>>>>      </RollingFile>
>> >>>>>  </Appenders>
>> >>>>>  <Loggers>
>> >>>>>      <Logger name="root" level="debug" additivity="false">
>> >>>>>          <appender-ref ref="RollingFile" level="All"/>
>> >>>>>      </Logger>
>> >>>>>      <Root level="All" additivity="false">
>> >>>>>          <AppenderRef ref="RollingFile"/>
>> >>>>>      </Root>
>> >>>>>  </Loggers>
>> >>>>> </configuration>
>> >>>>
>> >>>> ---------------------------------------------------------------------
>> >>>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> <javascript:_e(%7B%7D,'cvml','log4j-user-unsubscribe@logging.apache.org');>
>> >>>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>> <javascript:_e(%7B%7D,'cvml','log4j-user-help@logging.apache.org');>
>> >>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> <javascript:_e(%7B%7D,'cvml','log4j-user-unsubscribe@logging.apache.org');>
>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>> <javascript:_e(%7B%7D,'cvml','log4j-user-help@logging.apache.org');>
>>
>>
>

Re: Logging complete exception trace.

Posted by Kiran Badi <ad...@aayushs.com>.
Ok I did the change to the pattern and now my pattern looks like,

 <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{2}: %m%xEx%n</pattern>

19/Sep/2015 09:29:13,975- mypackage.myclass: Got the DAO ExceptionError
inserting data to db. Column count doesn't match value count at row 1

No luck :)




On Fri, Sep 18, 2015 at 8:40 PM, Remko Popma <re...@gmail.com> wrote:

> Sorry, I made a mistake: %t prints out the Thread. Please replace %tEx
> with %xEx. Can you show the output of that?
>
> Also, what version of log4j are you using? 2.3?
>
> Sent from my iPhone
>
> > On 2015/09/18, at 23:27, Kiran Badi <ad...@aayushs.com> wrote:
> >
> > Ok here is the pattern changed  I tried
> >
> > <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}: %m%tEx%n</pattern>
> >
> > After doing this, I got this in logs,
> >
> > 18/Sep/2015 17:23:05,421- myclass: Got the DAO ExceptionError inserting
> > into database. Parameter index out of range (24 > number of parameters,
> > which is 23).http-bio-8084-exec-35Ex
> >
> >
> > All my classes are giving single line exception message,
> >
> > How do I debug this issue now ?
> >
> >
> >
> >
> >
> >> On Fri, Sep 18, 2015 at 2:57 PM, Remko Popma <re...@gmail.com>
> wrote:
> >>
> >> Hmm, your source code looks correct. In your config, you could probably
> >> remove the named logger entry.
> >>>>> <Logger name="root" level="debug" additivity="false">
> >>>>>          <appender-ref ref="RollingFile" level="All"/>
> >>>>>      </Logger>
> >>
> >>
> >> The <Root> alone is sufficient I think.
> >> But this won't solve the issue...
> >>
> >> Do you see this behavior everywhere or only in some places?
> >> If you replace %ex in your pattern with %tEx, location info will be
> added
> >> to the output. This may help pinpoint the code that generates the log
> entry
> >> so you can double check it...
> >>
> >> Sorry I don't have a better answer.
> >>
> >> Remko
> >>
> >> Sent from my iPhone
> >>
> >>> On 2015/09/18, at 20:05, Kiran Badi <ad...@aayushs.com> wrote:
> >>>
> >>> Thanks Remko for reply, I think that's how I do it.
> >>>
> >>> Please see below the way I use it. I am on log4j2 and I have log4j-api,
> >>> log4j-core and log4j-web jars in the lib directory of my web app.
> >>>
> >>> I import these 2 packages
> >>> import org.apache.logging.log4j.LogManager;
> >>> import org.apache.logging.log4j.Logger;
> >>>
> >>>
> >>> Create a static instance
> >>>
> >>> static final Logger log =
> LogManager.getLogger(myclass.class.getName());
> >>>
> >>> then do use it in class file
> >>>
> >>>                 catch (Exception ex) {
> >>>                        log.error("Got the exception", ex);
> >>>                   }
> >>>
> >>> I was under impression that this should log the complete trace, but its
> >> not.
> >>>
> >>> Any ideas as what I am missing ?
> >>>
> >>>
> >>>
> >>>
> >>>> On Fri, Sep 18, 2015 at 1:49 PM, Remko Popma <re...@gmail.com>
> >> wrote:
> >>>>
> >>>> In your application,
> >>>> do not use logger.error(exception);
> >>>> but use logger.error("some message", exception); instead.
> >>>>
> >>>> The first form will take the exception object as an object and calls
> >>>> toString() on it, which is not what you want.
> >>>>
> >>>> Remko
> >>>>
> >>>> Sent from my iPhone
> >>>>
> >>>>> On 2015/09/18, at 18:00, Kiran Badi <ad...@aayushs.com> wrote:
> >>>>>
> >>>>> Hi All,
> >>>>>
> >>>>> I have below log42 xml in classes folder and I am on log4j2 . This
> >>>> setting
> >>>>> does not log exception and it just logs1 line exception.
> >>>>>
> >>>>> How do I make log4j2 to log complete exception trace in mysite log ?
> >>>>>
> >>>>>
> >>>>>
> >>>>> <?xml version="1.0" encoding="UTF-8"?>
> >>>>> <!--
> >>>>> To change this template, choose Tools | Templates
> >>>>> and open the template in the editor.
> >>>>> -->
> >>>>> <configuration>
> >>>>>  <Properties>
> >>>>>       <Property name="log-path">C:/logs/</Property>
> >>>>> <!--       <Property
> name="log-path">/home/mydrive/logs/</Property>-->
> >>>>>  </Properties>
> >>>>>  <Appenders>
> >>>>>      <RollingFile name="RollingFile"
> fileName="${log-path}/mysite.log"
> >>>>>
> >>>>> filePattern="${log-path}/indianads-%d{yyyy-MM-dd}-%i.log">
> >>>>>          <PatternLayout>
> >>>>>              <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}:
> >>>>> %m%ex%n</pattern>
> >>>>>          </PatternLayout>
> >>>>>          <Policies>
> >>>>>              <SizeBasedTriggeringPolicy size="1 MB"/>
> >>>>>          </Policies>
> >>>>>          <DefaultRolloverStrategy max="24"/>
> >>>>>      </RollingFile>
> >>>>>  </Appenders>
> >>>>>  <Loggers>
> >>>>>      <Logger name="root" level="debug" additivity="false">
> >>>>>          <appender-ref ref="RollingFile" level="All"/>
> >>>>>      </Logger>
> >>>>>      <Root level="All" additivity="false">
> >>>>>          <AppenderRef ref="RollingFile"/>
> >>>>>      </Root>
> >>>>>  </Loggers>
> >>>>> </configuration>
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> >>>> For additional commands, e-mail: log4j-user-help@logging.apache.org
> >>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>

Re: Logging complete exception trace.

Posted by Remko Popma <re...@gmail.com>.
Sorry, I made a mistake: %t prints out the Thread. Please replace %tEx with %xEx. Can you show the output of that?

Also, what version of log4j are you using? 2.3?

Sent from my iPhone

> On 2015/09/18, at 23:27, Kiran Badi <ad...@aayushs.com> wrote:
> 
> Ok here is the pattern changed  I tried
> 
> <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}: %m%tEx%n</pattern>
> 
> After doing this, I got this in logs,
> 
> 18/Sep/2015 17:23:05,421- myclass: Got the DAO ExceptionError inserting
> into database. Parameter index out of range (24 > number of parameters,
> which is 23).http-bio-8084-exec-35Ex
> 
> 
> All my classes are giving single line exception message,
> 
> How do I debug this issue now ?
> 
> 
> 
> 
> 
>> On Fri, Sep 18, 2015 at 2:57 PM, Remko Popma <re...@gmail.com> wrote:
>> 
>> Hmm, your source code looks correct. In your config, you could probably
>> remove the named logger entry.
>>>>> <Logger name="root" level="debug" additivity="false">
>>>>>          <appender-ref ref="RollingFile" level="All"/>
>>>>>      </Logger>
>> 
>> 
>> The <Root> alone is sufficient I think.
>> But this won't solve the issue...
>> 
>> Do you see this behavior everywhere or only in some places?
>> If you replace %ex in your pattern with %tEx, location info will be added
>> to the output. This may help pinpoint the code that generates the log entry
>> so you can double check it...
>> 
>> Sorry I don't have a better answer.
>> 
>> Remko
>> 
>> Sent from my iPhone
>> 
>>> On 2015/09/18, at 20:05, Kiran Badi <ad...@aayushs.com> wrote:
>>> 
>>> Thanks Remko for reply, I think that's how I do it.
>>> 
>>> Please see below the way I use it. I am on log4j2 and I have log4j-api,
>>> log4j-core and log4j-web jars in the lib directory of my web app.
>>> 
>>> I import these 2 packages
>>> import org.apache.logging.log4j.LogManager;
>>> import org.apache.logging.log4j.Logger;
>>> 
>>> 
>>> Create a static instance
>>> 
>>> static final Logger log = LogManager.getLogger(myclass.class.getName());
>>> 
>>> then do use it in class file
>>> 
>>>                 catch (Exception ex) {
>>>                        log.error("Got the exception", ex);
>>>                   }
>>> 
>>> I was under impression that this should log the complete trace, but its
>> not.
>>> 
>>> Any ideas as what I am missing ?
>>> 
>>> 
>>> 
>>> 
>>>> On Fri, Sep 18, 2015 at 1:49 PM, Remko Popma <re...@gmail.com>
>> wrote:
>>>> 
>>>> In your application,
>>>> do not use logger.error(exception);
>>>> but use logger.error("some message", exception); instead.
>>>> 
>>>> The first form will take the exception object as an object and calls
>>>> toString() on it, which is not what you want.
>>>> 
>>>> Remko
>>>> 
>>>> Sent from my iPhone
>>>> 
>>>>> On 2015/09/18, at 18:00, Kiran Badi <ad...@aayushs.com> wrote:
>>>>> 
>>>>> Hi All,
>>>>> 
>>>>> I have below log42 xml in classes folder and I am on log4j2 . This
>>>> setting
>>>>> does not log exception and it just logs1 line exception.
>>>>> 
>>>>> How do I make log4j2 to log complete exception trace in mysite log ?
>>>>> 
>>>>> 
>>>>> 
>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>> <!--
>>>>> To change this template, choose Tools | Templates
>>>>> and open the template in the editor.
>>>>> -->
>>>>> <configuration>
>>>>>  <Properties>
>>>>>       <Property name="log-path">C:/logs/</Property>
>>>>> <!--       <Property name="log-path">/home/mydrive/logs/</Property>-->
>>>>>  </Properties>
>>>>>  <Appenders>
>>>>>      <RollingFile name="RollingFile" fileName="${log-path}/mysite.log"
>>>>> 
>>>>> filePattern="${log-path}/indianads-%d{yyyy-MM-dd}-%i.log">
>>>>>          <PatternLayout>
>>>>>              <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}:
>>>>> %m%ex%n</pattern>
>>>>>          </PatternLayout>
>>>>>          <Policies>
>>>>>              <SizeBasedTriggeringPolicy size="1 MB"/>
>>>>>          </Policies>
>>>>>          <DefaultRolloverStrategy max="24"/>
>>>>>      </RollingFile>
>>>>>  </Appenders>
>>>>>  <Loggers>
>>>>>      <Logger name="root" level="debug" additivity="false">
>>>>>          <appender-ref ref="RollingFile" level="All"/>
>>>>>      </Logger>
>>>>>      <Root level="All" additivity="false">
>>>>>          <AppenderRef ref="RollingFile"/>
>>>>>      </Root>
>>>>>  </Loggers>
>>>>> </configuration>
>>>> 
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>>>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>> 

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Logging complete exception trace.

Posted by Kiran Badi <ad...@aayushs.com>.
Ok here is the pattern changed  I tried

<pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}: %m%tEx%n</pattern>

After doing this, I got this in logs,

18/Sep/2015 17:23:05,421- myclass: Got the DAO ExceptionError inserting
into database. Parameter index out of range (24 > number of parameters,
which is 23).http-bio-8084-exec-35Ex


All my classes are giving single line exception message,

How do I debug this issue now ?





On Fri, Sep 18, 2015 at 2:57 PM, Remko Popma <re...@gmail.com> wrote:

> Hmm, your source code looks correct. In your config, you could probably
> remove the named logger entry.
> >>> <Logger name="root" level="debug" additivity="false">
> >>>           <appender-ref ref="RollingFile" level="All"/>
> >>>       </Logger>
>
>
> The <Root> alone is sufficient I think.
> But this won't solve the issue...
>
> Do you see this behavior everywhere or only in some places?
> If you replace %ex in your pattern with %tEx, location info will be added
> to the output. This may help pinpoint the code that generates the log entry
> so you can double check it...
>
> Sorry I don't have a better answer.
>
> Remko
>
> Sent from my iPhone
>
> > On 2015/09/18, at 20:05, Kiran Badi <ad...@aayushs.com> wrote:
> >
> > Thanks Remko for reply, I think that's how I do it.
> >
> > Please see below the way I use it. I am on log4j2 and I have log4j-api,
> > log4j-core and log4j-web jars in the lib directory of my web app.
> >
> > I import these 2 packages
> > import org.apache.logging.log4j.LogManager;
> > import org.apache.logging.log4j.Logger;
> >
> >
> > Create a static instance
> >
> > static final Logger log = LogManager.getLogger(myclass.class.getName());
> >
> > then do use it in class file
> >
> >                  catch (Exception ex) {
> >                         log.error("Got the exception", ex);
> >                    }
> >
> > I was under impression that this should log the complete trace, but its
> not.
> >
> > Any ideas as what I am missing ?
> >
> >
> >
> >
> >> On Fri, Sep 18, 2015 at 1:49 PM, Remko Popma <re...@gmail.com>
> wrote:
> >>
> >> In your application,
> >> do not use logger.error(exception);
> >> but use logger.error("some message", exception); instead.
> >>
> >> The first form will take the exception object as an object and calls
> >> toString() on it, which is not what you want.
> >>
> >> Remko
> >>
> >> Sent from my iPhone
> >>
> >>> On 2015/09/18, at 18:00, Kiran Badi <ad...@aayushs.com> wrote:
> >>>
> >>> Hi All,
> >>>
> >>> I have below log42 xml in classes folder and I am on log4j2 . This
> >> setting
> >>> does not log exception and it just logs1 line exception.
> >>>
> >>> How do I make log4j2 to log complete exception trace in mysite log ?
> >>>
> >>>
> >>>
> >>> <?xml version="1.0" encoding="UTF-8"?>
> >>> <!--
> >>> To change this template, choose Tools | Templates
> >>> and open the template in the editor.
> >>> -->
> >>> <configuration>
> >>>   <Properties>
> >>>        <Property name="log-path">C:/logs/</Property>
> >>> <!--       <Property name="log-path">/home/mydrive/logs/</Property>-->
> >>>   </Properties>
> >>>   <Appenders>
> >>>       <RollingFile name="RollingFile" fileName="${log-path}/mysite.log"
> >>>
> >>> filePattern="${log-path}/indianads-%d{yyyy-MM-dd}-%i.log">
> >>>           <PatternLayout>
> >>>               <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}:
> >>> %m%ex%n</pattern>
> >>>           </PatternLayout>
> >>>           <Policies>
> >>>               <SizeBasedTriggeringPolicy size="1 MB"/>
> >>>           </Policies>
> >>>           <DefaultRolloverStrategy max="24"/>
> >>>       </RollingFile>
> >>>   </Appenders>
> >>>   <Loggers>
> >>>       <Logger name="root" level="debug" additivity="false">
> >>>           <appender-ref ref="RollingFile" level="All"/>
> >>>       </Logger>
> >>>       <Root level="All" additivity="false">
> >>>           <AppenderRef ref="RollingFile"/>
> >>>       </Root>
> >>>   </Loggers>
> >>> </configuration>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> >> For additional commands, e-mail: log4j-user-help@logging.apache.org
> >>
> >>
>

Re: Logging complete exception trace.

Posted by Remko Popma <re...@gmail.com>.
Hmm, your source code looks correct. In your config, you could probably remove the named logger entry. 
>>> <Logger name="root" level="debug" additivity="false">
>>>           <appender-ref ref="RollingFile" level="All"/>
>>>       </Logger>


The <Root> alone is sufficient I think. 
But this won't solve the issue...

Do you see this behavior everywhere or only in some places?
If you replace %ex in your pattern with %tEx, location info will be added to the output. This may help pinpoint the code that generates the log entry so you can double check it...

Sorry I don't have a better answer.

Remko

Sent from my iPhone

> On 2015/09/18, at 20:05, Kiran Badi <ad...@aayushs.com> wrote:
> 
> Thanks Remko for reply, I think that's how I do it.
> 
> Please see below the way I use it. I am on log4j2 and I have log4j-api,
> log4j-core and log4j-web jars in the lib directory of my web app.
> 
> I import these 2 packages
> import org.apache.logging.log4j.LogManager;
> import org.apache.logging.log4j.Logger;
> 
> 
> Create a static instance
> 
> static final Logger log = LogManager.getLogger(myclass.class.getName());
> 
> then do use it in class file
> 
>                  catch (Exception ex) {
>                         log.error("Got the exception", ex);
>                    }
> 
> I was under impression that this should log the complete trace, but its not.
> 
> Any ideas as what I am missing ?
> 
> 
> 
> 
>> On Fri, Sep 18, 2015 at 1:49 PM, Remko Popma <re...@gmail.com> wrote:
>> 
>> In your application,
>> do not use logger.error(exception);
>> but use logger.error("some message", exception); instead.
>> 
>> The first form will take the exception object as an object and calls
>> toString() on it, which is not what you want.
>> 
>> Remko
>> 
>> Sent from my iPhone
>> 
>>> On 2015/09/18, at 18:00, Kiran Badi <ad...@aayushs.com> wrote:
>>> 
>>> Hi All,
>>> 
>>> I have below log42 xml in classes folder and I am on log4j2 . This
>> setting
>>> does not log exception and it just logs1 line exception.
>>> 
>>> How do I make log4j2 to log complete exception trace in mysite log ?
>>> 
>>> 
>>> 
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <!--
>>> To change this template, choose Tools | Templates
>>> and open the template in the editor.
>>> -->
>>> <configuration>
>>>   <Properties>
>>>        <Property name="log-path">C:/logs/</Property>
>>> <!--       <Property name="log-path">/home/mydrive/logs/</Property>-->
>>>   </Properties>
>>>   <Appenders>
>>>       <RollingFile name="RollingFile" fileName="${log-path}/mysite.log"
>>> 
>>> filePattern="${log-path}/indianads-%d{yyyy-MM-dd}-%i.log">
>>>           <PatternLayout>
>>>               <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}:
>>> %m%ex%n</pattern>
>>>           </PatternLayout>
>>>           <Policies>
>>>               <SizeBasedTriggeringPolicy size="1 MB"/>
>>>           </Policies>
>>>           <DefaultRolloverStrategy max="24"/>
>>>       </RollingFile>
>>>   </Appenders>
>>>   <Loggers>
>>>       <Logger name="root" level="debug" additivity="false">
>>>           <appender-ref ref="RollingFile" level="All"/>
>>>       </Logger>
>>>       <Root level="All" additivity="false">
>>>           <AppenderRef ref="RollingFile"/>
>>>       </Root>
>>>   </Loggers>
>>> </configuration>
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>> 
>> 

Re: Logging complete exception trace.

Posted by Kiran Badi <ad...@aayushs.com>.
Thanks Remko for reply, I think that's how I do it.

 Please see below the way I use it. I am on log4j2 and I have log4j-api,
log4j-core and log4j-web jars in the lib directory of my web app.

I import these 2 packages
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;


Create a static instance

 static final Logger log = LogManager.getLogger(myclass.class.getName());

then do use it in class file

                  catch (Exception ex) {
                         log.error("Got the exception", ex);
                    }

I was under impression that this should log the complete trace, but its not.

Any ideas as what I am missing ?




On Fri, Sep 18, 2015 at 1:49 PM, Remko Popma <re...@gmail.com> wrote:

> In your application,
> do not use logger.error(exception);
> but use logger.error("some message", exception); instead.
>
> The first form will take the exception object as an object and calls
> toString() on it, which is not what you want.
>
> Remko
>
> Sent from my iPhone
>
> > On 2015/09/18, at 18:00, Kiran Badi <ad...@aayushs.com> wrote:
> >
> > Hi All,
> >
> > I have below log42 xml in classes folder and I am on log4j2 . This
> setting
> > does not log exception and it just logs1 line exception.
> >
> > How do I make log4j2 to log complete exception trace in mysite log ?
> >
> >
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <!--
> > To change this template, choose Tools | Templates
> > and open the template in the editor.
> > -->
> > <configuration>
> >    <Properties>
> >         <Property name="log-path">C:/logs/</Property>
> > <!--       <Property name="log-path">/home/mydrive/logs/</Property>-->
> >    </Properties>
> >    <Appenders>
> >        <RollingFile name="RollingFile" fileName="${log-path}/mysite.log"
> >
> > filePattern="${log-path}/indianads-%d{yyyy-MM-dd}-%i.log">
> >            <PatternLayout>
> >                <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}:
> > %m%ex%n</pattern>
> >            </PatternLayout>
> >            <Policies>
> >                <SizeBasedTriggeringPolicy size="1 MB"/>
> >            </Policies>
> >            <DefaultRolloverStrategy max="24"/>
> >        </RollingFile>
> >    </Appenders>
> >    <Loggers>
> >        <Logger name="root" level="debug" additivity="false">
> >            <appender-ref ref="RollingFile" level="All"/>
> >        </Logger>
> >        <Root level="All" additivity="false">
> >            <AppenderRef ref="RollingFile"/>
> >        </Root>
> >    </Loggers>
> > </configuration>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>

Re: Logging complete exception trace.

Posted by Remko Popma <re...@gmail.com>.
In your application, 
do not use logger.error(exception);
but use logger.error("some message", exception); instead. 

The first form will take the exception object as an object and calls toString() on it, which is not what you want. 

Remko

Sent from my iPhone

> On 2015/09/18, at 18:00, Kiran Badi <ad...@aayushs.com> wrote:
> 
> Hi All,
> 
> I have below log42 xml in classes folder and I am on log4j2 . This setting
> does not log exception and it just logs1 line exception.
> 
> How do I make log4j2 to log complete exception trace in mysite log ?
> 
> 
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <!--
> To change this template, choose Tools | Templates
> and open the template in the editor.
> -->
> <configuration>
>    <Properties>
>         <Property name="log-path">C:/logs/</Property>
> <!--       <Property name="log-path">/home/mydrive/logs/</Property>-->
>    </Properties>
>    <Appenders>
>        <RollingFile name="RollingFile" fileName="${log-path}/mysite.log"
> 
> filePattern="${log-path}/indianads-%d{yyyy-MM-dd}-%i.log">
>            <PatternLayout>
>                <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}:
> %m%ex%n</pattern>
>            </PatternLayout>
>            <Policies>
>                <SizeBasedTriggeringPolicy size="1 MB"/>
>            </Policies>
>            <DefaultRolloverStrategy max="24"/>
>        </RollingFile>
>    </Appenders>
>    <Loggers>
>        <Logger name="root" level="debug" additivity="false">
>            <appender-ref ref="RollingFile" level="All"/>
>        </Logger>
>        <Root level="All" additivity="false">
>            <AppenderRef ref="RollingFile"/>
>        </Root>
>    </Loggers>
> </configuration>

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org