标签: error-logging

在ColdFusion中,如何提取和存储提交表单的内容?

我正在ColdFusion中编写一个应用程序,尽管它基本上是稳定的,但它经常出错.因为它已经取代了旧的应用程序,有时候会出现错误的用户而不是我.

我创建了一个很好的页面,人们在收到向我发送信息的错误时会得到这个页面,例如错误,引用,错误在哪个页面,行号等.

我唯一看不到的就是提交表格数据,如果有的话.我事先不知道它错误的页面,所以我不能只输出'#form.field#'.

例如,如果:

form.abc = 1
form.def = 2
Run Code Online (Sandbox Code Playgroud)

如何在不事先知道的情况下从'form'获取变量名称和值?

这个文档是否在正确的路径上的某个结构上循环

另外,我在寻找一种存储在数据库中的数据,因为这是存储有关错误的其他信息的好方法,我真的不希望有把它在一封电子邮件给我.

database coldfusion error-logging

4
推荐指数
1
解决办法
3661
查看次数

.net框架错误日志位置在哪里

我的应用程序无缘无故退出,很可能是由于我使用的分析器中的错误,因为它干扰了所有CLR运行时的东西.问题是.Net框架记录这些错误的任何位置是否有任何文件?

.net error-logging

4
推荐指数
2
解决办法
3万
查看次数

将MAMP日志文件添加到MaxOSX控制台

将MAMP Apache,PHP和MySQL错误日志添加到MacOSX控制台的命令是什么?

谢谢!

macos console error-logging mamp

4
推荐指数
2
解决办法
3544
查看次数

将log4net与asp.net Web表单结合使用

我正在尝试将log4net合并到我的Web应用程序中.我已经使用基于.net mvc的新部分完成了这项工作,但是我很难将其合并到我的应用程序的基于Web表单的部分中.我环顾四周寻找一个例子并没有遇到过.

为了缩小我的问题范围,让我们假设我知道如何配置我的web.config文件.我的问题是:

(1)我考虑将实际调用log4net放在"Global.asax"文件中,并将其放在我的基页(构建所有其他页面)上.我应该将实际代码放在这些地方中的哪一个,如果不是,我应该把代码放在哪里?

(2)我对代码的理解是我需要实例化一个日志,然后在我想要的时候记录日志(日志的细节由web.config处理),但我不知道该代码应该是什么样子.那么,我应该在我的文件中放置什么代码?(例如,将不胜感激)

谢谢

c# asp.net log4net error-logging

4
推荐指数
1
解决办法
1万
查看次数

C++中获取调用函数的名称、行号和文件名

我编写了以下代码来将日志写入我的日志文件中。这段代码可以很好地记录消息,但现在我必须将其集成到多个文件中,我需要调用者的文件路径、调用者函数名称和行号。

请帮助我实现这一目标。

#include "Source.h"

bool CLogManager::fileOpenError = false;
std::string CLogManager::logFileName = "";
CLogManager* CLogManager::logManager = NULL;
FILE* CLogManager::file = NULL;

CLogManager :: CLogManager(){}
CLogManager :: ~CLogManager()
{
    if (file)
        fclose(file);
}
CLogManager* CLogManager::getInstance()
{
    if(logManager==NULL)
    {
        logManager = new CLogManager();
        logFileName = currentDateTime();
    }
    return logManager;
}
const std::string CLogManager::currentDateTime()
{
    time_t now = time(0);
    char currTime[30];
    strftime(currTime, sizeof(currTime), "Log_%Y_%m_%dT%H_%M_%S.xml", localtime(&now));
    return currTime;
}
void CLogManager::Log (char *message)
{
    file = fopen(logFileName.c_str(), "a+");
    if(file == NULL) 
    {
        if(fileOpenError == false) …
Run Code Online (Sandbox Code Playgroud)

c++ error-logging

4
推荐指数
1
解决办法
8358
查看次数

出错时退出子程序并将错误返回给调用错误子程序的子程序

一些背景:

前奏:我已经查看了其他错误处理问题,但我无法完全将答案应用于我的情况。我感到Err.Raise这就是我将如何完成我将在下面描述的事情。但是,我不确定如何以我需要的方式实现它。如果我要使用,Err.Raise如何在主子中引发错误代码之前先退出 Sub1-15?

话虽如此,

我有一个大型 Excel VBA 项目,它执行大量不同的例程。我选择从一个主例程中调用所有例程,以便以后维护各个例程。我有一个On Error处理程序,如果从该主例程调用的任何例程中抛出错误,我希望触发该处理程序。

有没有办法:

  1. 记录
    • 发生的错误类型
    • 错误信息
    • 引发错误的子项
  2. 出现错误时退出该子程序以返回主子程序,然后
    • 引发另一个子中刚刚发生的错误,以便调用NotifyandRepair错误处理程序?

我有以下情况

Sub MainSub()
    On Error GoTo NotifyandCorrect
    Call Sub1
    Call Sub2
    ...
    Call Sub15
    Exit Sub
NotifyandCorrect:
    'Send copy of faulty file, the error code and Sub that caused it
    'Then stop macro execution completely
End Sub

Sub Sub1()
    On Error Exit Sub1 and raise current Error in MainSub(?)
    'Perform data checks
End Sub

Sub Sub2() …
Run Code Online (Sandbox Code Playgroud)

error-handling excel vba error-logging

4
推荐指数
1
解决办法
8038
查看次数

将日志记录 basicConfig 与多个处理程序一起使用

我试图了解将 basicConfig 与多个处理程序一起使用时日志记录模块的行为。

我的目标是对系统日志消息设置警告级别,对日志文件设置调试级别。

这是我的设置:

import logging
import logging.handlers
import os
from datetime import datetime
 
log_format = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
f_handler = logging.FileHandler(f'{os.path.expanduser("~")}/logs/test_{datetime.now().strftime("%Y%m%d%H%M%S")}.log')
s_handler = logging.handlers.SysLogHandler(address='/dev/log')


f_handler.setLevel(logging.DEBUG)
s_handler.setLevel(logging.WARN)
f_handler.setFormatter(log_format)
s_handler.setFormatter(log_format)

logging.basicConfig(handlers=[f_handler, s_handler])

print (logging.getLogger().getEffectiveLevel())


logging.warning('This is a warning')
logging.error('This is an error')
logging.info('This is an info')
logging.debug('This is debug')
Run Code Online (Sandbox Code Playgroud)

这不起作用 - 我的日志文件仅包含警告和错误消息,而不是预期的调试和信息消息。

如果我将此行更改为:

logging.basicConfig(handlers=[f_handler, s_handler], level=logging.DEBUG)
Run Code Online (Sandbox Code Playgroud)

那么这似乎确实有效,即该文件包含所有消息,而系统日志仅包含错误和警告消息。

我不明白为什么原始代码不起作用,因为我专门在文件处理程序上设置了级别。

python logging error-logging

4
推荐指数
1
解决办法
1226
查看次数

使用Python的日志记录模块记录错误

我正在使用python的日志记录模块记录错误.我在我的课程中创建了一个logger对象,如下所示:

self.my_logger = logging.getLogger('my_logger')
self.my_logger.setLevel(logging.ERROR)
Run Code Online (Sandbox Code Playgroud)

当我尝试在代码中稍后记录错误时,如下所示:

self.my_logger.error("My error")
Run Code Online (Sandbox Code Playgroud)

然后我得到错误:

AttributeError: FileHandler instance has no attribute 'filters'
Run Code Online (Sandbox Code Playgroud)

更详细的错误日志是:

  File "/lib/python2.6/logging/__init__.py", line 1047, in error
    self._log(ERROR, msg, args, **kwargs)
  File "/lib/python2.6/logging/__init__.py", line 1129, in _log
    self.handle(record)
  File "/lib/python2.6/logging/__init__.py", line 1139, in handle
    self.callHandlers(record)
  File "/lib/python2.6/logging/__init__.py", line 1176, in callHandlers
    hdlr.handle(record)
  File "/lib/python2.6/logging/__init__.py", line 658, in handle
    rv = self.filter(record)
  File "/lib/python2.6/logging/__init__.py", line 558, in filter
    for f in self.filters:
AttributeError: FileHandler instance has no attribute 'filters'
Run Code Online (Sandbox Code Playgroud)

在上游,这是我设置文件处理程序的方式:

 if self.log_dir != None:
    self.log_filename …
Run Code Online (Sandbox Code Playgroud)

python error-handling logging error-logging

3
推荐指数
1
解决办法
8556
查看次数

错误未写入Apache错误日志

我遇到了一些Apache Web服务器错误日志的问题。

我的计算机上有一个虚拟托管的网站scotthermmann.loc。在我手动清除错误日志后,使用

sudo cat /dev/null > scotthermmann.loc-error_log
Run Code Online (Sandbox Code Playgroud)

或者通过在emacs中打开文件并删除所有内容,错误将不再记录到文件中。我试过使用

sudo apachectl restart
Run Code Online (Sandbox Code Playgroud)

解决问题,但不能解决。注销并重新登录也无法解决。解决问题的方法是重新启动计算机,但是每次清除错误日志后,我都不想这样做。

我托管的每个网站都并非如此。我有另一个网站nudefootfool.loc。清除错误日志后,我没有任何问题。

两个虚拟站点在httpd-vhosts.conf文件中的设置基本相同。对于scottherrmann.loc:

<VirtualHost *:80>
    DocumentRoot "/Users/dan/Sites/scottherrmann.com"
    ServerName scottherrmann.loc
    ServerAlias www.scottherrmann.loc
    ErrorLog "/private/var/log/apache2/scottherrmann.loc-error_log"
    CustomLog "/private/var/log/apache2/scottherrmann.loc-access_log"

    <Directory "/Users/dan/Sites/scottherrmann.com">
        Options Indexes FollowSymLinks
        AllowOverride All
        Order Allow,Deny
        Allow from all 
    </Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

而对于footfootfool.loc:

<VirtualHost *:80>
    DocumentRoot "/Users/dan/Sites/barefootfool.com"
    ServerName barefootfool.loc
    ServerAlias www.barefootfool.loc
    ErrorLog "/private/var/log/apache2/barefootfool.loc-error_log"
    CustomLog "/private/var/log/apache2/barefootfool.loc-access_log"

    <Directory "/Users/dan/Sites/barefootfool.com">
        Options Indexes FollowSymLinks
        AllowOverride All
        Order Allow,Deny
        Allow from all 
    </Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

有谁知道是什么原因引起的问题?

php apache error-logging

3
推荐指数
2
解决办法
9270
查看次数

Python日志记录不会使用basicConfig设置日志记录级别

出于某种原因, logging.basicConfig忽略了我给它的记录器级别.我的脚本中包含以下代码:

# main.py
print logging.getLogger().getEffectiveLevel()
print logger_level
logging.basicConfig(format=logger_format,
                    level=logger_level,
                    )
print logging.getLogger().getEffectiveLevel()
Run Code Online (Sandbox Code Playgroud)

输出是:

30
10
30
Run Code Online (Sandbox Code Playgroud)

因此,它实际上并没有设置记录器级别.但是,如果我在交互式解释器中执行此确切代码,我会得到以下输出:

30
10
10
Run Code Online (Sandbox Code Playgroud)

这意味着我正在设置日志记录级别.更令人困惑的是,这是最近发生的事情 - 我不知道我做了什么导致了这种行为.谁能提供一些见解?

编辑:如果遇到相关问题,我已尝试main.py从我的IDE(Sublime Text)和命令行运行,两者都具有相同的结果.我在一个基于conda的虚拟环境中工作,我尝试在环境中运行代码而不是(但只能从解释器 - 脚本无法处理一般环境),结果相同.

python logging error-logging

3
推荐指数
2
解决办法
1171
查看次数

标签 统计

error-logging ×10

logging ×3

python ×3

error-handling ×2

.net ×1

apache ×1

asp.net ×1

c# ×1

c++ ×1

coldfusion ×1

console ×1

database ×1

excel ×1

log4net ×1

macos ×1

mamp ×1

php ×1

vba ×1