1

I created a content rule to run a logger action, when a new content is added viz a file. When I run the view of the zinstance.log file,on linux I see all the logs. I wish to send the output for each logger action separately to another log file, so that it contains log concerned to that rule only where ever applicable in the Plone site. How can this be achieved. Is there any add-on for the same ? I know that we can grep the o/p and pipe it to a CSV for formatting it later.

0

1 Answer 1

-1

This can be achieved in two ways, these two methods are differentiated in Step 3:

Step 1: Records are generally written in a line in zinstance.log. (There are some instances where it is written in multiple lines, so you need to handle exceptions). So here you can use readline function to read each record.

Step 2: After reading record, and writing to respective places where ever you wnat using writelines.

Step 3: After reading and writing records, now you have two choices:

Method 1: You can copy the zinstance.log till whereever you have read to other location(subtitled with date and time, so that you will have logs always available) and create a new empty zinstance.log (Server will automatically write new logs to the new file, which will be available to you when ever you will run your program next time) at the location wherever it was.

Method 2: You can also keep the pointer to the position, till wherever you have read, in a file, which is read next time you are running your program and start reading records from that position. This method may lead to unreliability, as if file size goes above the range of data type, then it will curropt the pointer till wherever you have read. Since log files are large enough, so its better not to take this approach

Hope this will answer your concern

1
  • I want to automate it in Plone rather than do it manually as you mentioned. Further I want to create different logfiles for different rules e.g. A log file when a new content is added, another log file for content deleted -this has to come automatically from plone :)
    – user956424
    Jul 20, 2012 at 3:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.