You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by abhishek reddy <ab...@gmail.com> on 2009/06/22 14:32:03 UTC

Regarding log4J creating logs in tomcat logs folder using FileAppender

hi every one,

Iam new to Log4j.......

How to create log files in tomcat logs folder using Apache Log4j
FileAppender class?

This is what i was doing....

new FileAppender(layout,"todayslog",true);

but the log files are created under tomcat bin folder...........how t change
this?

Also let me know how to create a folder under tomcat logs folder.....
when i give the filename as "mylogs\\todayslog" it is throwing
"FileNotFoundException"

----need help regarding

thanks in advance

-- 
Abhishek

RE: Regarding log4J creating logs in tomcat logs folder using FileAppender

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com]
> Subject: RE: Regarding log4J creating logs in tomcat logs folder using
> FileAppender
> 
> > but the log files are created under tomcat bin folder
>
> Because you're using a relative path, which should be avoided, since
> you have no control over it.  You can retrieve the Tomcat base path
> from the system property tomcat.base; Tomcat logs are normally in the
> logs directory under tomcat.base.
> 
> > Also let me know how to create a folder under tomcat logs folder.....
> 
> This is a Java, not Tomcat question; use java.io.File.mkdir(), or do it
> from a command line shell.  Note that hard-coding a backslash as a file
> separator makes your code non-portable.

Another point: the location of the log4j output is normally specified in a log4j.properties or log4j.xml file to make reconfiguration easier; why are you trying to do this programmatically?

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Regarding log4J creating logs in tomcat logs folder using FileAppender

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: abhishek reddy [mailto:abhishek.c1984@gmail.com]
> Subject: Re: Regarding log4J creating logs in tomcat logs folder using
> FileAppender
> 
> i think it is "catalina.base"

Yes, sorry for the earlier misdirect.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Regarding log4J creating logs in tomcat logs folder using FileAppender

Posted by abhishek reddy <ab...@gmail.com>.
Now it is working......thanks for the reply....

On Mon, Jun 22, 2009 at 6:45 PM, abhishek reddy <ab...@gmail.com>wrote:

> i think it is "catalina.base"
>
>
> On Mon, Jun 22, 2009 at 6:41 PM, abhishek reddy <ab...@gmail.com>wrote:
>
>> thanks for the reply.....
>>
>> How to retrieve the tomcat base path?
>>
>> I have tried this way System.getProperty("tomcat.base");............the
>> value is comming as null
>>
>>
>> On Mon, Jun 22, 2009 at 6:25 PM, Caldarale, Charles R <
>> Chuck.Caldarale@unisys.com> wrote:
>>
>>> > From: abhishek reddy [mailto:abhishek.c1984@gmail.com]
>>> > Subject: Regarding log4J creating logs in tomcat logs folder using
>>> > FileAppender
>>> >
>>> > but the log files are created under tomcat bin folder
>>>
>>> Because you're using a relative path, which should be avoided, since you
>>> have no control over it.  You can retrieve the Tomcat base path from the
>>> system property tomcat.base; Tomcat logs are normally in the logs directory
>>> under tomcat.base.
>>>
>>> > Also let me know how to create a folder under tomcat logs folder.....
>>>
>>> This is a Java, not Tomcat question; use java.io.File.mkdir(), or do it
>>> from a command line shell.  Note that hard-coding a backslash as a file
>>> separator makes your code non-portable.
>>>
>>>  - Chuck
>>>
>>>
>>> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
>>> MATERIAL and is thus for use only by the intended recipient. If you received
>>> this in error, please contact the sender and delete the e-mail and its
>>> attachments from all computers.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>
>>
>> --
>> Abhishek
>>
>
>
>
> --
> Abhishek
>



-- 
Abhishek

Re: Regarding log4J creating logs in tomcat logs folder using FileAppender

Posted by abhishek reddy <ab...@gmail.com>.
i think it is "catalina.base"

On Mon, Jun 22, 2009 at 6:41 PM, abhishek reddy <ab...@gmail.com>wrote:

> thanks for the reply.....
>
> How to retrieve the tomcat base path?
>
> I have tried this way System.getProperty("tomcat.base");............the
> value is comming as null
>
>
> On Mon, Jun 22, 2009 at 6:25 PM, Caldarale, Charles R <
> Chuck.Caldarale@unisys.com> wrote:
>
>> > From: abhishek reddy [mailto:abhishek.c1984@gmail.com]
>> > Subject: Regarding log4J creating logs in tomcat logs folder using
>> > FileAppender
>> >
>> > but the log files are created under tomcat bin folder
>>
>> Because you're using a relative path, which should be avoided, since you
>> have no control over it.  You can retrieve the Tomcat base path from the
>> system property tomcat.base; Tomcat logs are normally in the logs directory
>> under tomcat.base.
>>
>> > Also let me know how to create a folder under tomcat logs folder.....
>>
>> This is a Java, not Tomcat question; use java.io.File.mkdir(), or do it
>> from a command line shell.  Note that hard-coding a backslash as a file
>> separator makes your code non-portable.
>>
>>  - Chuck
>>
>>
>> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
>> MATERIAL and is thus for use only by the intended recipient. If you received
>> this in error, please contact the sender and delete the e-mail and its
>> attachments from all computers.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>
>
> --
> Abhishek
>



-- 
Abhishek

Re: Regarding log4J creating logs in tomcat logs folder using FileAppender

Posted by abhishek reddy <ab...@gmail.com>.
thanks for the reply.....

How to retrieve the tomcat base path?

I have tried this way System.getProperty("tomcat.base");............the
value is comming as null

On Mon, Jun 22, 2009 at 6:25 PM, Caldarale, Charles R <
Chuck.Caldarale@unisys.com> wrote:

> > From: abhishek reddy [mailto:abhishek.c1984@gmail.com]
> > Subject: Regarding log4J creating logs in tomcat logs folder using
> > FileAppender
> >
> > but the log files are created under tomcat bin folder
>
> Because you're using a relative path, which should be avoided, since you
> have no control over it.  You can retrieve the Tomcat base path from the
> system property tomcat.base; Tomcat logs are normally in the logs directory
> under tomcat.base.
>
> > Also let me know how to create a folder under tomcat logs folder.....
>
> This is a Java, not Tomcat question; use java.io.File.mkdir(), or do it
> from a command line shell.  Note that hard-coding a backslash as a file
> separator makes your code non-portable.
>
>  - Chuck
>
>
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you received
> this in error, please contact the sender and delete the e-mail and its
> attachments from all computers.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


-- 
Abhishek

RE: Regarding log4J creating logs in tomcat logs folder using FileAppender

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: abhishek reddy [mailto:abhishek.c1984@gmail.com]
> Subject: Regarding log4J creating logs in tomcat logs folder using
> FileAppender
> 
> but the log files are created under tomcat bin folder

Because you're using a relative path, which should be avoided, since you have no control over it.  You can retrieve the Tomcat base path from the system property tomcat.base; Tomcat logs are normally in the logs directory under tomcat.base.

> Also let me know how to create a folder under tomcat logs folder.....

This is a Java, not Tomcat question; use java.io.File.mkdir(), or do it from a command line shell.  Note that hard-coding a backslash as a file separator makes your code non-portable.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org