powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Java [игнор отключен] [закрыт для гостей] / log4j:WARN No appenders could be found for logger (использую Spring)
3 сообщений из 3, страница 1 из 1
log4j:WARN No appenders could be found for logger (использую Spring)
    #33009729
Alexey Turn
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
При старте кота вываливаются эти красные ванинги:

log4j:WARN No appenders could be found for logger (org.apache.commons.digester.Digester).
log4j:WARN Please initialize the log4j system properly.

в WEB-INF/ лежит файл log4.properties

Это кусок web.xml

<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>

</listener>

<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.properties</param-value>
</context-param>

<servlet>
<servlet-name>context</servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>


в чем проблема?
...
Рейтинг: 0 / 0
log4j:WARN No appenders could be found for logger (использую Spring)
    #33010042
concat
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
вообщето log4j.properties должен находиться в WEB-INF/classes а не в WEB-INF
...
Рейтинг: 0 / 0
log4j:WARN No appenders could be found for logger (использую Spring)
    #33010134
А.Грасоff™ JE
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
для полноты картины:

http://logging.apache.org/log4j/docs/manual.html
Default Initialization under Tomcat

The default log4j initialization is particularly useful in web-server environments. Under
Tomcat 3.x and 4.x, you should place the log4j.properties under the WEB-INF/classes
directory of your web-applications. Log4j will find the properties file and initialize itself.
This is easy to do and it works.

You can also choose to set the system property log4j.configuration before starting
Tomcat. For Tomcat 3.x The TOMCAT_OPTS environment variable is used to set
command line options. For Tomcat 4.0, set the CATALINA_OPTS environment variable
instead of TOMCAT_OPTS.

...

Example 4

The Windows shell command

Код: plaintext
set TOMCAT_OPTS=-Dlog4j.configuration=file:/c:/foobar.lcf

tells log4j to use the file c:\foobar.lcf as the default configuration file. The
configuration file is fully specified by the URL file:/c:/foobar.lcf. Thus, the same
configuration file will be used for all web-applications.

...

Initialization servlet

It is also possible to use a special servlet for log4j initialization. Here is an example,
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
 package  com.foo;

 import  org.apache.log4j.PropertyConfigurator;
 import  javax.servlet.http.HttpServlet;
 import  javax.servlet.http.HttpServletRequest;
 import  javax.servlet.http.HttpServletResponse;
 import  java.io.PrintWriter;
 import  java.io.IOException;

 public   class  Log4jInit  extends  HttpServlet {

   public 
   void  init() {
    String prefix =  getServletContext().getRealPath("/");
    String file = getInitParameter("log4j-init-file");
    // if the log4j-init-file is not set, then no point in trying
     if (file !=  null ) {
      PropertyConfigurator.configure(prefix+file);
    }
  }

   public 
   void  doGet(HttpServletRequest req, HttpServletResponse res) {
  }
}

Define the following servlet in the web.xml file for your web-application.

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
  <servlet>
    <servlet-name>log4j-init</servlet-name>
    <servlet-class>com.foo.Log4jInit</servlet-class>

    <init-param>
      <param-name>log4j-init-file</param-name>
      <param-value>WEB-INF/classes/log4j.lcf</param-value>
    </init-param>

    <load-on-startup> 1 </load-on-startup>
  </servlet>

Writing an initialization servlet is the most flexible way for initializing log4j. There are
no constraints on the code you can place in the init() method of the servlet.
...
Рейтинг: 0 / 0
3 сообщений из 3, страница 1 из 1
Форумы / Java [игнор отключен] [закрыт для гостей] / log4j:WARN No appenders could be found for logger (использую Spring)
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]