1

I have simple log, and it does do it's job, but for unknown reasons it also creates folder "target" and empty "camel-spring-redis-test.log" inside. The log.properties below

    log4j.rootLogger=INFO, file
    log4j.appender.file=org.apache.log4j.RollingFileAppender
    log4j.appender.LOGFILE.Append=false
    log4j.appender.file.File=res/logfile.log
    log4j.appender.file.MaxFileSize=1MB
    log4j.appender.file.layout=org.apache.log4j.PatternLayout
    log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

Maybe the reason in Apache Camel, used in this project? How to forbid creation of theese things?

Dmitresso
  • 145
  • 1
  • 8
  • Ah yeah sadly the log4j.properties file was not in the test directory - this will be fixed in next Camel releases: https://github.com/apache/camel/commit/ae6ea22833b9705472e16c7d0b1663508057f29e – Claus Ibsen Dec 26 '15 at 08:01

2 Answers2

0

Maybe you are right, because Apache Camel uses log4j too (via sfl4j). This link shows how to enable logs on Camel.

You may try addind this line to your log.properties and see if it works

log4j.logger.org.apache.camel=OFF
kkk
  • 818
  • 8
  • 11
0

It involves using Spring Redis component (http://camel.apache.org/spring-redis.html). The bungle of this component contains the file log4.properties http://grepcode.com/file/repo1.maven.org/maven2/org.apache.camel/camel-spring-redis/2.12.0/log4j.properties?av=f

You have to work on configuring the logging in your infrastructure to forbid creation camel-spring-redis-test.log. What kind of server are you using for running Apache Camel? The solution will depend on your servers log settings.

Alexey Yakunin
  • 1,743
  • 1
  • 19
  • 21
  • Camel runs on my local machine, without any server – Dmitresso Dec 24 '15 at 10:45
  • You should put your log4j.properties in the root resources folder of your project. For example: `src\main\resources\log4j.properties`. – Alexey Yakunin Dec 24 '15 at 10:51
  • These two topics can help you: http://stackoverflow.com/questions/2716824/where-how-does-log4j-look-for-a-log4j-properties-file http://stackoverflow.com/questions/2594689/external-log4j-xml-file – Alexey Yakunin Dec 24 '15 at 11:15
  • Another one: http://stackoverflow.com/questions/4866259/log4j-picking-up-wrong-properties-file – Alexey Yakunin Dec 24 '15 at 11:20
  • Thank you for interesting topics, I got them, but problem they describe has small difference with mine. That's good example in the 1-st link, and if I properly understood, that problem's in missing `.config` file (log4j can't find the path and use default configurations). Maybe I used incorrect words, but my logger works unquestioningly, it writes log where i pointed to it to do, but besides it my logger creates folder "target" with empty "camel-spring-redis-test.log" inside. It doesn't disturbes me, but there is some some mistake I'm trying to detect. – Dmitresso Dec 24 '15 at 11:54
  • Your application use not only one configuration of log4j. I think application discover your own log4j.properties after when log4j.properties from Spring Redist and create folder an file before your own configuration to be used. You need to some how to disable discovering log4j.properties from Spring Redist before your own config. I think, using `log4j.xml` or, maybe starting your application with key `-Dlog4j.configuration=...` pointing to your config file will help you. – Alexey Yakunin Dec 24 '15 at 12:12
  • http://stackoverflow.com/questions/18761729/spring-camel-camel-logs-by-default-goes-console-appender something like my problem – Dmitresso Dec 24 '15 at 12:28
  • You're absolutely allright, after some manipulations i found that `target` folder creation ends before my `PropertyConfigurator.configure("res/config.properties");` starts to work (because logging works even if i remove this code) – Dmitresso Dec 24 '15 at 13:08
  • Is your log4j config file have name `config.properties`? If so, rename it to log4j.properties and try again. – Alexey Yakunin Dec 24 '15 at 13:32
  • Just because log4j.properties is default value of log4j configuration file name :) You are welcome! – Alexey Yakunin Dec 24 '15 at 13:45