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 Ch...@bertelsmann.de on 2007/01/04 14:34:26 UTC

Log memory usage of the java virtual machine

Hi,

I'm searching for a solution to add the memory usage of the java virtual machine to every log4j entry. At the moment I can access only manually the memory usage with the help of:

double free =  Runtime.getRuntime().freeMemory() / 1024d / 1024d;
double max =  Runtime.getRuntime().maxMemory() / 1024d / 1024d;
double total =  Runtime.getRuntime().totalMemory() / 1024d / 1024d;

I'm using the logger at many different positions so it would be a very bad solution to add these values every time manually to the logger-output. Is it possible to add these values automatically to every logger-output?

--C.P.

Re: Log memory usage of the java virtual machine

Posted by Maarten Bosteels <mb...@gmail.com>.
On 1/4/07, James Stauffer <st...@gmail.com> wrote:
> You could make your own appender and add the info there or make your
> own layout class to add support for including it in the output.

but I think, what you really need is a memory profile like Yourkit Java profiler

Maarten

>
> On 1/4/07, Christoph.Paschedag@bertelsmann.de
> <Ch...@bertelsmann.de> wrote:
> > Hi,
> >
> > I'm searching for a solution to add the memory usage of the java virtual machine to every log4j entry. At the moment I can access only manually the memory usage with the help of:
> >
> > double free =  Runtime.getRuntime().freeMemory() / 1024d / 1024d;
> > double max =  Runtime.getRuntime().maxMemory() / 1024d / 1024d;
> > double total =  Runtime.getRuntime().totalMemory() / 1024d / 1024d;
> >
> > I'm using the logger at many different positions so it would be a very bad solution to add these values every time manually to the logger-output. Is it possible to add these values automatically to every logger-output?
> >
> > --C.P.
> >
> >
>
>
> --
> James Stauffer        http://www.geocities.com/stauffer_james/
> Are you good? Take the test at http://www.livingwaters.com/good/
>
> ---------------------------------------------------------------------
> 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: Log memory usage of the java virtual machine

Posted by James Stauffer <st...@gmail.com>.
You could make your own appender and add the info there or make your
own layout class to add support for including it in the output.

On 1/4/07, Christoph.Paschedag@bertelsmann.de
<Ch...@bertelsmann.de> wrote:
> Hi,
>
> I'm searching for a solution to add the memory usage of the java virtual machine to every log4j entry. At the moment I can access only manually the memory usage with the help of:
>
> double free =  Runtime.getRuntime().freeMemory() / 1024d / 1024d;
> double max =  Runtime.getRuntime().maxMemory() / 1024d / 1024d;
> double total =  Runtime.getRuntime().totalMemory() / 1024d / 1024d;
>
> I'm using the logger at many different positions so it would be a very bad solution to add these values every time manually to the logger-output. Is it possible to add these values automatically to every logger-output?
>
> --C.P.
>
>


-- 
James Stauffer        http://www.geocities.com/stauffer_james/
Are you good? Take the test at http://www.livingwaters.com/good/

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