我有两个ASP.NET MVC Web应用程序.其中一个将未处理的异常记录到Windows事件日志中.另一个没有.
IIS或web.config中是否有设置以启用事件日志记录?
对于广泛的问题道歉,我真的在寻找调查途径.
我有PHP弃用的错误洪水日志文件和Drupal状态页面如下:
: Function ereg() is deprecated in mysite/includes/file.inc on line 893.
Run Code Online (Sandbox Code Playgroud)
我应该可以关闭我的php.ini中的E_DEPRECATED错误,但它设置为:尽管设置为:
error_reporting = E_ALL & ~E_DEPRECATED
Run Code Online (Sandbox Code Playgroud)
phpInfo()报告error_reporting主值和本地值22527.
我做了一个
grep -R error_reporting
Run Code Online (Sandbox Code Playgroud)
在我的文档根目录,希望找到任何硬编码错误级别,没有运气:
./includes/common.inc: // If the @ error suppression operator was used, error_reporting will have
./includes/common.inc: if (error_reporting() == 0) {
./modules/system/system.module: 'page arguments' => array('system_error_reporting_settings'),
./modules/system/system.admin.inc:function system_error_reporting_settings() {
./modules/system/system.install: $err = error_reporting(0);
./modules/system/system.install: error_reporting($err);
Run Code Online (Sandbox Code Playgroud)
除了可能是system.install中的第一行之外,我什么都看不到,但是如果我是对的,应该关闭所有错误.
我没有在.htaccess中设置error_reporting,但这样做也没有任何效果.
我希望有一个解决方案不涉及common.inc中的硬编码错误级别(哪些工作,我已经尝试过 - 但显然是不受欢迎的).
我知道已弃用的错误是升级到PHP 5.3的结果,但降级PHP不是选项(新站点现在在5.3上测试的同一台服务器上运行,发生这些错误的站点有2个月的生命).我也无法升级到与5.3很好地兼容的Drupal版本,因为不幸的是前任所有者在不记录他的更改的情况下对核心模块进行了管理.
版本的东西:
PHP 5.3.2-1,Ubuntu 10.04,Drupal 6.13在一个站点上,6.5(!! 1!)在另一个站点上,Apache 2.2
我想在Python中使用"logging"模块将错误写入日志文件.但是,我希望只在出现错误时才创建文件.我使用以下代码:
import logging
f = 'test.conf'
logger = logging.getLogger("test_logger")
logger.setLevel(logging.INFO)
ch_file = logging.FileHandler("test_logger.conf")
ch_file.setLevel(logging.ERROR)
logger.addHandler(ch_file)
ch_file.close()
ch = logging.StreamHandler()
ch.setLevel(logging.INFO)
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
ch.setFormatter(formatter)
logger.addHandler(ch)
logger.info("info")
logger.warn("warning")
#logger.error("error")
Run Code Online (Sandbox Code Playgroud)
当取消注释logger.error("error")时,我希望文件"test_logger.conf"中包含错误.但是,当该行被注释掉时,我发现test_logger.conf文件仍然是空的.除非有错误报告,否则我怎么能这样做才能生成这个文件?
谢谢.
我基本上加载了Elmah程序集并使用NuGet插件安装了程序包.我记得它与我的一个项目合作,但突然间它停止了工作
"无法从程序集'Elmah'中加载'Elmah.ErrorLogModule'类型."
错误,这很奇怪.它曾经工作过.无论如何,我在Google上找不到很多解决方案,但我认为之前人们已经遇到过这个问题.有人建议它是32位64位版本问题.
有什么建议?
是否可以将相同的错误发送到/ var/log/php_errors中的全局php错误日志,以及将相同的错误发送到/ var/www/mysite/php_errors中的本地错误日志?
在我们的登台服务器上,我拖尾日志文件,很多wordpress的东西以及一些丑陋的print_r将来自其他开发人员.我想要一个全局错误文件来查看是否有任何不时破坏服务器的内容,以及将我的本地错误分开,以便我可以更好地关注它们如果我现在只对一个站点感兴趣.
除非有一个类似的代码行,否则throw new NullPointerException();通常会出现一个空指针,当一个表达式null被操作时.所以,我的问题是,为什么空指针的消息不包含返回null的表达式?
java error-logging exception-handling exception nullpointerexception
我有一个日志格式化程序,当前将所有常规日志级别格式化为 json 字符串。当我想查看日志时,我使用带有 javascript 的网页将 json 转换为 's in a table。我使用的格式化程序是:
formatter = logging.Formatter(
'{"datetime":"%(asctime)s","level":"%(levelname)s","app":"%(app_name)s","module":"%(module)s",' +
'"line":"%(lineno)d","function":"%(funcName)s","msg":"%(msg)s"}' #<switch2>'
)
Run Code Online (Sandbox Code Playgroud)
这工作正常。我现在想使用 logging.exception() 记录异常。
似乎 logging.exception 不提供在所有其他日志记录级别中找到的项目的字典。
如何捕获 logging.exception 提供的堆栈跟踪,以便我可以将其转换为与我为所有其他类型的日志条目创建的 json 兼容的形式?对于 logging.exception,我需要的是获取堆栈跟踪并将其放入 json 的“msg”元素中。如果 logging.exception 不提供其他 dict 元素,如 asctime、level 等,我可以自己即时创建它们。
我有一个用 Python 编写的 Heroku 应用程序。当它失败时,它不会记录任何内容,只是在失败的位置停止代码执行(它不会执行下面的打印语句),然后继续运行,什么也没有发生。
如何在日志中显示异常错误和回溯?使用该raise语句引发异常时的行为是否有所不同?
我在配置文件中设置了以下内容:
DEBUG = True
PRESERVE_CONTEXT_ON_EXCEPTION = True
Run Code Online (Sandbox Code Playgroud)
试过和不试PRESERVE_CONTEXT_ON_EXCEPTION。
有人可以帮助我解决NLog使用登录到数据库AsyncTargetWrapper并且连接有问题的情况吗?我如何获取/拦截那些异常(因为异步目标不会抛出异常)?这似乎是一个很常见的情况,所以我很难相信这InternalLogger是唯一的选择。这是一个示例项目(需要安装NLog nuget软件包):
using System;
using System.Threading;
using NLog;
using NLog.Common;
using NLog.Config;
using NLog.Targets;
using NLog.Targets.Wrappers;
class Program
{
static void Main(string[] args)
{
LogManager.ThrowExceptions = true;
InternalLogger.LogToConsole = true;
InternalLogger.LogLevel = LogLevel.Error;
var conf = new LoggingConfiguration();
var target = new DatabaseTarget
{
ConnectionString =
"Server=BAD_SERVER;Database=foo;",
CommandText = "INSERT INTO logs(message) VALUES ('bar')"
};
var asyncTarget = new AsyncTargetWrapper(target);
var rule = new LoggingRule("*", LogLevel.Trace, asyncTarget);
conf.LoggingRules.Add(rule);
LogManager.Configuration = conf;
Logger logger = LogManager.GetLogger("Example");
logger.Info("Message"); …Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个高度模块化的 Python 日志系统(使用日志模块),并在日志消息中包含来自跟踪模块的信息。
例如,我希望能够编写如下一行代码:
my_logger.log_message(MyLogFilter, "this is a message")
Run Code Online (Sandbox Code Playgroud)
并让它包括对“log_message”调用位置的跟踪,而不是实际的记录器调用本身。
除了跟踪信息来自logging.debug()调用而不是调用之外,我几乎可以使用以下代码my_logger.log_message()。
class MyLogFilter(logging.Filter):
def __init__(self):
self.extra = {"error_code": 999}
self.level = "debug"
def filter(self, record):
for key in self.extra.keys():
setattr(record, key, self.extra[key])
class myLogger(object):
def __init__(self):
fid = logging.FileHandler("test.log")
formatter = logging.Formatter('%(pathname)s:%(lineno)i, %(error_code)%I, %(message)s'
fid.setFormatter(formatter)
self.my_logger = logging.getLogger(name="test")
self.my_logger.setLevel(logging.DEBUG)
self.my_logger.addHandler(fid)
def log_message(self, lfilter, message):
xfilter = lfilter()
self.my_logger.addFilter(xfilter)
log_funct = getattr(self.logger, xfilter.level)
log_funct(message)
if __name__ == "__main__":
logger = myLogger()
logger.log_message(MyLogFilter, "debugging")
Run Code Online (Sandbox Code Playgroud)
为了进行简单的logging.debug调用,要经历很多麻烦,但实际上,我将MyLogFilter …