配置日志以捕获失败的用户登录尝试

时间:2015-04-28 02:40:59

标签: apache tomcat logging configure

我正在尝试配置日志记录以捕获失败的用户登录尝试。我想我一切都很好,但没有看到我指定的目录中的日志(或任何超出正常的基本日志记录)。

我在哪里错误配置?

**server.xml** *Just the section in question*

Valve className="org.apache.catalina.valves.AccessLogValve"
directory="D:/Software/logs" prefix="localhost." suffix=".txt" pattern="%h %l %u %t '%r' %s %b" resolveHosts="false"/> 

**logging.properties**

handlers =      1catalina.org.apache.juli.FileHandler, \ 
                2localhost.org.apache.juli.FileHandler, \ 
                3manager.org.apache.juli.FileHandler, \ 
                4host-manager.org.apache.juli.FileHandler, \ 
                java.util.logging.ConsoleHandler, \ 
                5request-dumper.org.apache.juli.FileHandler \ 

 .handlers = 1catalina.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler 


############################################################ 
# Handler specific properties. 
# Describes specific configuration info for Handlers. 
############################################################ 

1catalina.org.apache.juli.FileHandler.level = FINE 
1catalina.org.apache.juli.FileHandler.directory = D:/Software/logs/ 
1catalina.org.apache.juli.FileHandler.prefix = catalina. 
1catalina.org.apache.juli.FileHandler.limit = 100000 # size 100MB 
1catalina.org.apache.juli.FileHandler.count = 5 


2localhost.org.apache.juli.FileHandler.level = FINE 
2localhost.org.apache.juli.FileHandler.directory = D:/Software/logs/ 
2localhost.org.apache.juli.FileHandler.prefix = localhost. 

3manager.org.apache.juli.FileHandler.level = FINE 
3manager.org.apache.juli.FileHandler.directory = D:/Software/logs/ 
3manager.org.apache.juli.FileHandler.prefix = manager. 

4host-manager.org.apache.juli.FileHandler.level = FINE 
4host-manager.org.apache.juli.FileHandler.directory = D:/Software/logs/ 
4host-manager.org.apache.juli.FileHandler.prefix = host-manager. 

java.util.logging.ConsoleHandler.level = FINE 
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter 

1 个答案:

答案 0 :(得分:0)

我看到你有一个ConsoleHandler,所以你在控制台上看到了日志吗?如果控制台不能正常工作,那么一般来说,您的日志配置可能存在问题。如果控制台正在运行,是否有任何错误消息?我会仔细检查路径名称,因为Windows对于转义的斜线字符来说有点棘手,但我认为你的路径会起作用。