我正在用 python 编写一个工具,我想将所有错误 - 并且仅将错误 - (未按应有的计算进行)放入单个日志文件中。此外,我希望在错误日志文件中为代码的每个部分提供不同的文本,以便使错误日志文件易于解释。我该如何编码?非常感谢谁能对此提供帮助!
动机:我想记录文件名、行号、函数名、错误代码等以帮助分析错误
Rust 必须?进行错误处理。如果?. 如何实现这一目标?
代码:
let a = do_some_function_may_return_error()?; // Does it auto log the error info when error occurs?
let b = a.do_another_function_may_return_error()?; // Does it auto log the error info when error occurs?
Run Code Online (Sandbox Code Playgroud) 虽然我的ASP.NET项目使用框架的3.5版本,但事件日志会将错误注册为来自框架的2.X版本,例如:
Event Type: Error
Event Source: ASP.NET 2.0.50727.0
Event Category: None
Event ID: 1334
Date: 2009-05-19
Time: 17:04:29
User: N/A
Computer: XXXXXXXXXX
Description:
An unhandled exception occurred and the process was terminated.
Application ID: /LM/W3SVC/234989001/Root
Process ID: 8912
Exception: System.Web.HttpException
Message: The remote host closed the connection. The error code is 0x80072746.
Run Code Online (Sandbox Code Playgroud) 我是Java.util包中的日志类的新手,我已经开发了一个应用程序,并希望在不同的级别实现日志记录机制,我只想到哪一个去找出它们之间的差异2.我正在寻找1)记录器应易于维护,可实现.任何人都可以对此提出建议.
我在我的代码库中有很多地方,我希望在出现问题时得到通知 - 我想象的很常见.查看以下代码,我如何重新考虑此方法以抽象出电子邮件/日志记录详细信息?目前,这分散在大约100个地方,我真的需要做点什么!
public bool MethodOne() {
string message;
bool success = new Task().Execute();
message = string.Format( "MethodOne was {0} successful.",
success ? "" : "not");
if( !success )
SMTP.send( to, from, message );
System.Diagnostic.EventLog.WriteEntry( executingAssembly, message);
return success;
};
Run Code Online (Sandbox Code Playgroud)
我目前的想法是做类似以下的事情:
public class Log
{
string to = "me@me.com",
from = "system@me.com",
subject = "Error occured";
public void Write( string executingAssembly, string message, bool sendEmail )
{
System.Diagnostic.EventLog.WriteEntry( executingAssembly, message);
if( sendEmail )
SendEmail( to, from, subject, message );
} …Run Code Online (Sandbox Code Playgroud) 我有一个大小为1677,25 MB的SQL Server数据库.这是我详细的数据库大小信息:
数据库大小:1677.25 MB
未分配空间:343.09 MB
保留:24488 KB数据:18560 KB索引大小:2632 KB未使用:3296 KB行数:74410
所以,你可以看到它并不是那么大的数据库.问题是,日志.
日志文件的大小为:1.311 GB
我该如何清理旧日志?好吧也许过去3个月很重要,但1.3 GB确实是一个重要的尺寸.
(ACF9)
除非有一个我缺少的选项,"记录慢于[n]秒的慢速页面"设置对于基于前端控制器的站点没有用(例如,Model-Glue,FW/1,Fusebox,Mach-II,等等.).
例如,在Mura/Framework-One网站中,我最终得到:
"Warning","jrpp-186","04/25/13","15:26:36",,"Thread: jrpp-186, processing template: /home/mysite/public_html_cms/wwwroot/index.cfm, completed in 11 seconds, exceeding the 10 second warning limit"
"Warning","jrpp-196","04/25/13","15:27:11",,"Thread: jrpp-196, processing template: /home/mysite/public_html_cms/wwwroot/index.cfm, completed in 59 seconds, exceeding the 10 second warning limit"
"Warning","jrpp-214","04/25/13","15:28:56",,"Thread: jrpp-214, processing template: /home/mysite/public_html_cms/wwwroot/index.cfm, completed in 32 seconds, exceeding the 10 second warning limit"
"Warning","jrpp-134","04/25/13","15:31:53",,"Thread: jrpp-134, processing template: /home/mysite/public_html_cms/wwwroot/index.cfm, completed in 11 seconds, exceeding the 10 second warning limit"
Run Code Online (Sandbox Code Playgroud)
有没有办法在那里获取查询字符串或发布详细信息,还是有另一种方式来获取我所追求的内容?
coldfusion monitoring error-logging front-controller coldfusion-9
在我的MVC解决方案中,我有两个处理程序用于例外.首先记录Logs数据库的异常:
public sealed class LogErrorAttribute : Attribute, IExceptionFilter
{
public void OnException(ExceptionContext filterContext)
{
// some handling with filterContext.Exception
}
}
Run Code Online (Sandbox Code Playgroud)
第二个显示用户异常:
public sealed class AsyncAwareHandleErrorAttribute : HandleErrorAttribute
{
public override void OnException(ExceptionContext filterContext)
{
// some handling with filterContext.Exception
}
}
Run Code Online (Sandbox Code Playgroud)
当发生任何未处理的异常时,它们都会被触发:
throw new ArgumentNullException("email", i18n.someErrorMessage);
Run Code Online (Sandbox Code Playgroud)
i18n.someErrorMessage是从resx文件中翻译的字符串.
在两个处理程序中filterContext.Exception.Message我都有已经翻译过的字符串.
如何仅在我的解决方案中CultureInfo.InvariantCulture设置了异常消息en-US?
c# error-logging exception-handling internationalization asp.net-mvc-4
我在 Toad 中为 oracle 创建了一个名为 error_log 的表。这样做的目的是记录以前编写的包可能遇到的任何错误,并记录它们以供开发人员查看。现在,我的任务是创建一个包/过程,它基本上会引发错误并能够将其记录到 error_log 表中?关于我将如何处理这件事的任何想法?
.net ×2
c# ×2
asp.net ×1
clr ×1
coldfusion ×1
coldfusion-9 ×1
java ×1
log4j ×1
logging ×1
monitoring ×1
oracle ×1
plsql ×1
python ×1
rust ×1
toad ×1