>> >> >
>> >> >
>> >> > Here is a sample test case....in python.
>> >> > Save below to a file and run it.
>> >> > python testfile.py
>> >> >
>> >> >
>> >> > #----testfile.py-----
>> >> > from logging.handlers import SysLogHandler
>> >> >
>> >> > import logging
>> >> >
>> >> >
>> >> > # create logger
>> >> > logger = logging.getLogger("myapp")
>> >> > logger.setLevel(logging.DEBUG)
>> >> > ch = SysLogHandler('/dev/log')
>> >> > ch.setLevel(logging.DEBUG)
>> >> > # create formatter
>> >> > formatter = logging.Formatter("%(asctime)s - %(name)s-
>> %(levelname)s -
>> >> > %(message)s")
>> >> > # add formatter to ch
>> >> > ch.setFormatter(formatter)
>> >> > logger.addHandler(ch)
>> >> > logger.info('This is a message')
>> >> >
>> >> >
>> >> > How can I setup rsyslog to filter "myapp" and save the messages to
1.
So in my code I've defined a formatter to be:
formatter = logging.Formatter("%(asctime)s - %(name)s- %(levelname)s -
%(message)s")
I don't care how it looks as long as it has a date, time, name of the
app, level, and message. Is there a standard formatting I should be
using? I don't want to create a custom solution if I can use standard
one?
2. What about saving the file with todays date. I don't want to rotate
the logs, but I want to have a file for each day saved in
/home/lucas/$year$month$date.txt
Above does not work, unless I'm missing some escape characters/parentheses?
Thanks,
Lucas
_______________________________________________
rsyslog mailing list
http://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com