gluscript logging

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

gluscript logging

sgillespie
In general, I'd like each mountPoint to have it's own deployment log.  If I'm not mistaken, the log property of a gluscript will send all messages to the agent log file.  Is there a (simple) way to configure it to write to it's own log file (possibly parameterized by mountPoint)?  If not, how would you approach this situation?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: gluscript logging

sgillespie
Here's a bit more of backstory.  Some of our deployments print to stdout/stderr and the output can be very valuable when verifying or debugging them.  For example, one of our scripts imports a bunch of stuff over some web services, and the output may be something like:

Uploading files to server1
Uploading files to server2

Updating domain1 at server1
Updating domain2 at server1
Updating domain1 at server2

and so on.  We have a large number of environments, so we could end up interleaving a lot of information in the agents log from a lot of different deployments.  In this case, I think that having all of the output in its own place simplifies the verification and debugging process.

I'm open to other suggestions and patterns of course.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: gluscript logging

frenchyan
Administrator
From a pure technical point of view the logger for a given mountPoint is obtained via slf4j/log4j there: https://github.com/pongasoft/glu/blob/master/agent/org.linkedin.glu.agent-impl/src/main/groovy/org/linkedin/glu/agent/impl/script/ScriptManagerImpl.groovy#L186

def log = LoggerFactory.getLogger("org.linkedin.glu.agent.script.${sd.mountPoint}")


It actually dumps everything on the console and the agent startup script is the one redirecting to a file. If you have a finite set of mountPoint and you already know what they are then I suppose you can modify the log4j.xml to create multiple files per mountPoint and then simply dispatch according to the name (ex: org.linkedin.glu.agent.script./x/i001)

I am not an expert in log4j but I am pretty sure you can create your own appender (maybe one already exists...) to achieve what you want more dynamically (meaning the filename is based on the last part of the logger name...)

Due to the easy way to package agent now (since 5.1.0), it would be fairly easy to add a jar file and provide your own log4j.xml to generate your own agent distribution.

I don't have much time to look into it myself at this time but will be happy to provide guidance/review.

Hope this helps.
Yan
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: gluscript logging

frenchyan
Administrator
Maybe a RoutingAppender can help you there: http://logging.apache.org/log4j/2.x/manual/appenders.html#RoutingAppender

Yan
Loading...