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 Adam Retter <ad...@googlemail.com> on 2015/06/09 21:08:54 UTC

Write log files relative to log4j2.xml?

Hi there,

Is it somehow possible to specify that the log4j2 log files should be
written somewhere relative to the configuration file?

For example my config file is here - /somewhere/my-app/logj2.xml

I would like to ensure that regardless of which folder my application
is started from then my log files are always written to -
/somewhere/my-app/var/log

My log4j2.xml has something like this -

        <RollingRandomAccessFile name="my-app"
filePattern="var/log/my-app.log.gz" fileName="var/log/my-app.log">
            <Policies>
                <SizeBasedTriggeringPolicy size="10MB"/>
            </Policies>
            <DefaultRolloverStrategy max="14"/>
            <PatternLayout pattern="%d [%t] %-5p (%F [%M]:%L) - %m %n"/>
        </RollingRandomAccessFile>

However, var/log/my-app.log is always written relative to the folder
where my-app is started from and not relative to where the config file
is.

Any ideas?

-- 
Adam Retter

skype: adam.retter
tweet: adamretter
http://www.adamretter.org.uk

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


Re: Write log files relative to log4j2.xml?

Posted by Adam Retter <ad...@googlemail.com>.
Okay thanks, I have submitted a patch here -
https://issues.apache.org/jira/browse/LOG4J2-1050

On 10 June 2015 at 01:08, Ralph Goers <ra...@dslextreme.com> wrote:
> Create a Jira issue. If you could actually create a patch the likelihood that it will get solved sooner is much higher.
>
> Ralhp
>
>> On Jun 9, 2015, at 3:08 PM, Adam Retter <ad...@googlemail.com> wrote:
>>
>> Okay thanks Ralph,
>>
>> How would I go about getting such a change submitted to the project?
>>
>> On 9 June 2015 at 22:36, Ralph Goers <ra...@dslextreme.com> wrote:
>>> There is nothing now but I would imagine it wouldn’t be too difficult to add a variable that contains the base url or path of the configuration file in use.
>>>
>>> Ralph
>>>
>>>> On Jun 9, 2015, at 12:08 PM, Adam Retter <ad...@googlemail.com> wrote:
>>>>
>>>> Hi there,
>>>>
>>>> Is it somehow possible to specify that the log4j2 log files should be
>>>> written somewhere relative to the configuration file?
>>>>
>>>> For example my config file is here - /somewhere/my-app/logj2.xml
>>>>
>>>> I would like to ensure that regardless of which folder my application
>>>> is started from then my log files are always written to -
>>>> /somewhere/my-app/var/log
>>>>
>>>> My log4j2.xml has something like this -
>>>>
>>>>       <RollingRandomAccessFile name="my-app"
>>>> filePattern="var/log/my-app.log.gz" fileName="var/log/my-app.log">
>>>>           <Policies>
>>>>               <SizeBasedTriggeringPolicy size="10MB"/>
>>>>           </Policies>
>>>>           <DefaultRolloverStrategy max="14"/>
>>>>           <PatternLayout pattern="%d [%t] %-5p (%F [%M]:%L) - %m %n"/>
>>>>       </RollingRandomAccessFile>
>>>>
>>>> However, var/log/my-app.log is always written relative to the folder
>>>> where my-app is started from and not relative to where the config file
>>>> is.
>>>>
>>>> Any ideas?
>>>>
>>>> --
>>>> Adam Retter
>>>>
>>>> skype: adam.retter
>>>> tweet: adamretter
>>>> http://www.adamretter.org.uk
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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
>>>
>>
>>
>>
>> --
>> Adam Retter
>>
>> skype: adam.retter
>> tweet: adamretter
>> http://www.adamretter.org.uk
>>
>> ---------------------------------------------------------------------
>> 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
>



-- 
Adam Retter

skype: adam.retter
tweet: adamretter
http://www.adamretter.org.uk

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


Re: Write log files relative to log4j2.xml?

Posted by Ralph Goers <ra...@dslextreme.com>.
Create a Jira issue. If you could actually create a patch the likelihood that it will get solved sooner is much higher.

Ralhp

> On Jun 9, 2015, at 3:08 PM, Adam Retter <ad...@googlemail.com> wrote:
> 
> Okay thanks Ralph,
> 
> How would I go about getting such a change submitted to the project?
> 
> On 9 June 2015 at 22:36, Ralph Goers <ra...@dslextreme.com> wrote:
>> There is nothing now but I would imagine it wouldn’t be too difficult to add a variable that contains the base url or path of the configuration file in use.
>> 
>> Ralph
>> 
>>> On Jun 9, 2015, at 12:08 PM, Adam Retter <ad...@googlemail.com> wrote:
>>> 
>>> Hi there,
>>> 
>>> Is it somehow possible to specify that the log4j2 log files should be
>>> written somewhere relative to the configuration file?
>>> 
>>> For example my config file is here - /somewhere/my-app/logj2.xml
>>> 
>>> I would like to ensure that regardless of which folder my application
>>> is started from then my log files are always written to -
>>> /somewhere/my-app/var/log
>>> 
>>> My log4j2.xml has something like this -
>>> 
>>>       <RollingRandomAccessFile name="my-app"
>>> filePattern="var/log/my-app.log.gz" fileName="var/log/my-app.log">
>>>           <Policies>
>>>               <SizeBasedTriggeringPolicy size="10MB"/>
>>>           </Policies>
>>>           <DefaultRolloverStrategy max="14"/>
>>>           <PatternLayout pattern="%d [%t] %-5p (%F [%M]:%L) - %m %n"/>
>>>       </RollingRandomAccessFile>
>>> 
>>> However, var/log/my-app.log is always written relative to the folder
>>> where my-app is started from and not relative to where the config file
>>> is.
>>> 
>>> Any ideas?
>>> 
>>> --
>>> Adam Retter
>>> 
>>> skype: adam.retter
>>> tweet: adamretter
>>> http://www.adamretter.org.uk
>>> 
>>> ---------------------------------------------------------------------
>>> 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
>> 
> 
> 
> 
> -- 
> Adam Retter
> 
> skype: adam.retter
> tweet: adamretter
> http://www.adamretter.org.uk
> 
> ---------------------------------------------------------------------
> 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: Write log files relative to log4j2.xml?

Posted by Adam Retter <ad...@googlemail.com>.
Okay thanks Ralph,

How would I go about getting such a change submitted to the project?

On 9 June 2015 at 22:36, Ralph Goers <ra...@dslextreme.com> wrote:
> There is nothing now but I would imagine it wouldn’t be too difficult to add a variable that contains the base url or path of the configuration file in use.
>
> Ralph
>
>> On Jun 9, 2015, at 12:08 PM, Adam Retter <ad...@googlemail.com> wrote:
>>
>> Hi there,
>>
>> Is it somehow possible to specify that the log4j2 log files should be
>> written somewhere relative to the configuration file?
>>
>> For example my config file is here - /somewhere/my-app/logj2.xml
>>
>> I would like to ensure that regardless of which folder my application
>> is started from then my log files are always written to -
>> /somewhere/my-app/var/log
>>
>> My log4j2.xml has something like this -
>>
>>        <RollingRandomAccessFile name="my-app"
>> filePattern="var/log/my-app.log.gz" fileName="var/log/my-app.log">
>>            <Policies>
>>                <SizeBasedTriggeringPolicy size="10MB"/>
>>            </Policies>
>>            <DefaultRolloverStrategy max="14"/>
>>            <PatternLayout pattern="%d [%t] %-5p (%F [%M]:%L) - %m %n"/>
>>        </RollingRandomAccessFile>
>>
>> However, var/log/my-app.log is always written relative to the folder
>> where my-app is started from and not relative to where the config file
>> is.
>>
>> Any ideas?
>>
>> --
>> Adam Retter
>>
>> skype: adam.retter
>> tweet: adamretter
>> http://www.adamretter.org.uk
>>
>> ---------------------------------------------------------------------
>> 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
>



-- 
Adam Retter

skype: adam.retter
tweet: adamretter
http://www.adamretter.org.uk

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


Re: Write log files relative to log4j2.xml?

Posted by Ralph Goers <ra...@dslextreme.com>.
There is nothing now but I would imagine it wouldn’t be too difficult to add a variable that contains the base url or path of the configuration file in use.

Ralph

> On Jun 9, 2015, at 12:08 PM, Adam Retter <ad...@googlemail.com> wrote:
> 
> Hi there,
> 
> Is it somehow possible to specify that the log4j2 log files should be
> written somewhere relative to the configuration file?
> 
> For example my config file is here - /somewhere/my-app/logj2.xml
> 
> I would like to ensure that regardless of which folder my application
> is started from then my log files are always written to -
> /somewhere/my-app/var/log
> 
> My log4j2.xml has something like this -
> 
>        <RollingRandomAccessFile name="my-app"
> filePattern="var/log/my-app.log.gz" fileName="var/log/my-app.log">
>            <Policies>
>                <SizeBasedTriggeringPolicy size="10MB"/>
>            </Policies>
>            <DefaultRolloverStrategy max="14"/>
>            <PatternLayout pattern="%d [%t] %-5p (%F [%M]:%L) - %m %n"/>
>        </RollingRandomAccessFile>
> 
> However, var/log/my-app.log is always written relative to the folder
> where my-app is started from and not relative to where the config file
> is.
> 
> Any ideas?
> 
> -- 
> Adam Retter
> 
> skype: adam.retter
> tweet: adamretter
> http://www.adamretter.org.uk
> 
> ---------------------------------------------------------------------
> 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