Log4j - Nome do Arquivo Dinâmico  XML
Índice dos Fóruns » Desenvolvimento Web
Autor Mensagem
micheljuca
JavaTeenager
[Avatar]

Membro desde: 11/08/2005 15:20:20
Mensagens: 184
Localização: Brasília - DF
Offline

pessoal, existe uma forma do log4j pegar o nome do contexto da aplicação para gerar o nome do arquivo [sistema].log ?

algo como:


--
Michel A. Jucá
thingol
Moderador

Membro desde: 29/07/2004 16:10:13
Mensagens: 17543
Offline

O nome do contexto eu não sei, mas segundo isto aqui:

http://logging.apache.org/log4j/docs/api/org/apache/log4j/PropertyConfigurator.html

você pode usar ${variavel} para obter acesso a uma System.getProperty ("variavel") ou a uma variável definida nesse arquivo .properties (não sei exatamente como)


All option values admit variable substitution. The syntax of variable substitution is similar to that of Unix shells. The string between an opening "${" and closing "}" is interpreted as a key. The value of the substituted variable can be defined as a system property or in the configuration file itself. The value of the key is first searched in the system properties, and if not found there, it is then searched in the configuration file being parsed. The corresponding value replaces the ${variableName} sequence. For example, if java.home system property is set to /home/xyz, then every occurrence of the sequence ${java.home} will be interpreted as /home/xyz.
[WWW]
micheljuca
JavaTeenager
[Avatar]

Membro desde: 11/08/2005 15:20:20
Mensagens: 184
Localização: Brasília - DF
Offline

é eu vi, a gente até usa o ${catalina.home}/log/arquivo.log

mas eu queria pegar o contexto mesmo. Pois estamos padronizando todos os logs das aplicações. Mas eu vou ler um pouco o link.

valeu pela ajuda.

--
Michel A. Jucá
 
Índice dos Fóruns » Desenvolvimento Web
Ir para:   
Powered by JForum 2.1.8 © JForum Team