简体   繁体   English

django网站中的日志记录错误所在的位置

[英]Where the logging errors located in a django website

I am a newbie in Django. 我是Django的新手。 I have a website created with Django + Apache. 我有一个使用Django + Apache创建的网站。 I imported logging module and print some intermediate values with logging error function. 我导入了日志记录模块,并使用日志记录错误功能打印了一些中间值。 But I don't know where the logging file locates. 但是我不知道日志文件在哪里。 The OS is Ubuntu. 操作系统是Ubuntu。

I searched internet and could not find a good answer (Maybe I did not do it properly). 我搜索了互联网,但找不到一个好的答案(也许我做得不好)。 Could someone tell me where can I find the logging file that contains the values I logged in the code? 有人可以告诉我在哪里可以找到包含我在代码中记录的值的日志文件吗?

Thanks. 谢谢。

Keep this in your settings and the filename specifies the location of the file 将其保留在您的设置中,文件名指定文件的位置

LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
    'verbose': {
        'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
    },
    'simple': {
        'format': '%(levelname)s %(message)s'
    },
},
'handlers': {
    'file_userlogins': {                # define and name a handler
        'level': 'DEBUG',
        'class': 'logging.FileHandler', # set the logging class to log to a file
        'formatter': 'verbose',         # define the formatter to associate
        'filename': os.path.join(VENV_ROOT, 'log', 'userlogins.log') # log file
    },
 'loggers': {
    'logview.userlogins': {              # define a logger - give it a name
        'handlers': ['file_userlogins'], # specify what handler to associate
        'level': 'INFO',                 # specify the logging level
        'propagate': True,
    },     
}       
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM