[ckan-dev] file logging in CKAN

Ross Jones ross at servercode.co.uk
Wed Feb 19 10:04:27 UTC 2014


You might want to not use file based logging, especially if you’re considering logging to it from multiple processes, apart from the problems you’re getting you’ll get truncated logs.

Setting up syslog is easy (and faster) and less prone to errors from multiple processes.

You can set it up with the following in your .ini file

[handlers]
keys = console, syslog

[formatters]
keys = generic

[logger_root]
level = WARNING
handlers = console, syslog

[logger_ckan]
level = DEBUG
handlers = console, syslog
qualname = ckan
propagate = 0

[logger_ckanext]
level = DEBUG
handlers = console, syslog
qualname = ckanext
propagate = 0

[handler_syslog]
class = logging.handlers.SysLogHandler
formatter = generic
args=('/dev/log', 'local0',)
level = DEBUG

[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic

[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s] %(message)s

Setting up rsyslog is easy,  for non-errors into /var/log/ckan/ckan.log in /etc/rsyslog.d/100-ckan.conf add

if $syslogfacility-text == 'local0' and not ($msg contains 'ERROR') then /var/log/ckan/ckan.log
& ~

and then for errors, in /etc/rsyslog.d/101-ckan.conf add 

if $syslogfacility-text == 'local0' and ($msg contains 'ERROR') then /var/log/ckan/ckan-error.log
& ~


On 19 Feb 2014, at 09:50, Hildegard Gerlach <hildegard.gerlach at jrc.ec.europa.eu> wrote:

> Hello,
> 
> I am using the following configuration in my CKAN development.ini configuration file for the extensions:
> 
> [logger_ckanext]
> level = DEBUG
> #level = INFO
> handlers = filelog_ext
> qualname = ckanext
> propagate = 0
> 
> [handler_filelog_ext]
> class = logging.handlers.RotatingFileHandler
> args = ("/var/log/ckan/ckan_ext.log", "a", 20000000, 9,)
> level = NOTSET
> formatter = generic
> 
> Every time the log file is rotated, it is created with permission 644. When I do harvesting from CKAN however, apache wants to write to this file and I get a permission error and have to set the permission manually. Is there a way to change this without having to rewrite the Python log handler ?
> 
> Thanks
> 
> Hilde
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev




More information about the ckan-dev mailing list