cancel
Showing results for 
Search instead for 
Did you mean: 

how to create a logfile from a library

Former Member
0 Kudos

Hi all,

I'm writing some code(redwoodScript/Java) in our sapcps V8 Environment.

I'm creating code to be used on  a library or/and a trigger.

for debugging purposes I would like to create a file on the application server FS  and log the debug information there.

using this

fdebug = new PrintWriter(new BufferedWriter(new FileWriter("/var/tmp/sapcpsdebug/trigger.log", true)));

I can get a logfile created. however every time the trigger executes it deletes the file and starts again.

I would like to know what is the better way to do this kind of thing.

Requirements is to have a separated file for this.

I think we should be able to use the logging classes to add a new log the the application server in order to perform a better usage of resources, but I'm a bit lost here.

any idea on how to do this, or were to look for more information?.

Regards.

Accepted Solutions (0)

Answers (1)

Answers (1)

nanda_kumar21
Active Contributor
0 Kudos

Get the current datetime from the system and append it to the file name.

This way you will have a different file everytime.

thanks

Nanda

Former Member
0 Kudos

Hi Nada,

That's a nice solution, but it does not what I really wanted/need

I would like to have only one file  and all the iterations of the tiggers writing to it.

I guess there have to be two solutions:

1 open always the same file for appending (it's costly and it's not working) that was my first approach.

2 I guess it has to be posible to create a new log like in the netweaver server and use it from the trigger not having to worry about open and close the log file. and having much better "performance" however I don't know how to create a new logger.

Regards.

Miguel Campos.

gmblom
Active Contributor
0 Kudos

Hello,

In a Library you can create your own Logger using:


package com.redwood.scheduler.custom.mycompany;

import com.redwood.scheduler.api.scripting.variables.LibraryLoggerFactory;

import com.redwood.scheduler.infrastructure.logging.api.Logger;

class YourClass

{

  Logger log = LibraryLoggerFactory.getLogger(YourClass.class);

  log.debug("Hello World");

}

Using the Job Definition System_DynamicTrace you can fetch the debug information by specifying custom.mycompony=debug as the trace string.

Regards Gerben

Former Member
0 Kudos

Hi Gerben,

  Thanks for your answer, that's the idea however doing it like that my question is to which file. fisically on the appserver will it write.

I have physical access to the unix FS  so I would like to do a tail -f XXXX and see my debug messages but only my debug messages  and I think that if we use this method the info will go to the mail log in the appserver.

Regards.

Miguel Campos.

gmblom
Active Contributor
0 Kudos

Hello Miguel,

In this case the messages (and only your messages) will be picked up by the System_DynamicTrace job, the nice thing is that the System_DynamicTrace has live feedback, so it shows you a tail -f from the UI directly.

Regards Gerben

Former Member
0 Kudos

Hi Gerben,

  I re-read your  your solution and enven if  it's not what I wanted originally its a useful one.

however I have a doubt.

"custom.mycompony=debug"

what is the literal "mycompony" stands for the jd_name, the class name I used to create the logger?  or what.

Regards.

Miguel campos.

gmblom
Active Contributor
0 Kudos

Hello,

The custom.company stands for the package name your class lives in. It will automatically take all classes from the package and its subpackages. If the package name starts with com.redwood.scheduler, you can leave that out and start with the bit after scheduler.

Regards Gerben