Debuging Asqatasun

Hi guys! I’m trying to debug some queries that i wrote in CriterionStatisticsDAOImpl and WebResourceStatisticsDAOImpl. What should i do to write LOGGER.DEBUG messages to a file and see them? I tried to configure Asqatasun/engine/asqatasun-api/src/test/resources/log4j.properties file like this:

 # Set root logger level to DEBUG and its only appender to CONSOLE.
#sortie console
log4j.rootLogger=DEBUG,file,CONSOLE_APP

# Direct log messages to a log file
log4j.appender.file=org.apache.log4j.RollingFileAppender

#Redirect to Tomcat logs folder
log4j.appender.file.File=${catalina.home}/logs/logging.log

but it didn’t work…Thanks!

Also replaced all INFO appearances by DEBUG in /Asqatasun/web-app/asqatasun-web-app/target/asqatasun-web-app-4.1.0-SNAPSHOT/WEB-INF/classes/log4j.properties but everytime i compile Asqatasun it changes back to INFO.

Hi @nivak91

As you may have already read, you’ve got an explanation on enabling logging in Asqatasun in the doc.

Before going on, one important thing must be understood in the build process:

  • Your sources are located in, say, /home/nivak91/sources/asqatasun/. When you code, these are the files you modify
  • When you build (mvn clean install), the artifacts (artifact = product of the build) are in the target/ directories.
  • Once built, you’ll want to test, thus install your Asqatasun:
    • If you never installed Asqatasun, grab the whole archive (from /home/nivak91/sources/asqatasun/web-app/asqatasun-web-app/target/, file asqatasun-4.1.0-SNAPSHOT.i386.tar.gz), unpack it and install Asqatasun (this is the long way).
    • If you’ve already installed Asqatasun on your machine, and you did not modify the DB schema, then you can copy the WAR file (grab it from /home/nivak91/sources/asqatasun/web-app/asqatasun-web-app/target/asqatasun-web-app-4.1.0-SNAPSHOT.war) and copy it into your Tomcat webapp directory, typically /var/lib/tomcat7/webapp/, no need to restart tomcat, just wait for the deployment to be done. This is the short way.
    • If you don’t want to bother with the installation stuff, you can use the Compile and build docker image script, which does what its name suggests with plenty of usefull options (-h option will give you everything). This is the :sunglasses: way.

That being said, from the paths you mention, I think you modified the log4j.properties that is deployed (i.e. after the build is done). Thus that’s no surprise you’ve got to modify it after each build.

To avoid this, you’d better modify directly the log4j.properties from the sources, which is located in <path-to-asqatasoun-sources>/web-app/asqatasun-web-app/src/main/resources/log4j.properties.

Your files (CriterionStatisticsDAOImpl and WebResourceStatisticsDAOImpl) are in the module org.asqatasun.entity.dao, so add the following line to your log4j.properties:

log4j.logger.org.asqatasun.entity.dao=DEBUG

Hope this helps !

2 Likes

hi @nivak91,

in a few words: don’t edit files in target directories and edit files in src directories

for the following file:
web-app/asqatasun-web-app/target/asqatasun-web-app-4.1.0-SNAPSHOT/WEB-INF/classes/log4j.properties

edit this file:
web-app/asqatasun-web-app/src/main/resources/log4j.properties

1 Like

Ok guys @fabrice @mfaure i edited web-app/asqatasun-web-app/src/main/resources/log4j.properties like this: Changed ERROR to DEBUG in log4j.rootLogger=DEBUG,FILE_APP and also added log4j.logger.org.asqatasun.webapp = DEBUG because i want to debug under this module. But when i add something like LOGGER.debug(“mesage”) in a class after of course declaring private static final Logger LOGGER = Logger.getLogger(SomeClass.class) in the class i want to debug i get nothing in /var/log/asqatasun.log…

hi @nivak91,

can you put here your log4j.properties file ?
can you tell us if you use Docker or Tomcat on your host ?

I have installed asqatasun on localhost:8080 and docker on localhost:8085.
This is log4j.properties:

# Set root logger level to DEBUG and its only appender to CONSOLE.
# console output
# file output
log4j.rootLogger=DEBUG,FILE_APP

# file output
log4j.appender.FILE_APP=org.apache.log4j.DailyRollingFileAppender
log4j.appender.FILE_APP.File=${logDir}/asqatasun.log
log4j.appender.FILE_APP.DatePattern='.'yyyy-MM-dd
log4j.appender.FILE_APP.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE_APP.layout.ConversionPattern=%d{dd-MM-yyyy HH:mm:ss:SSS} %-4r %-5p %c %x - %m%n

# Change the level of messages for various packages.
log4j.logger.com.mchange=INFO
log4j.logger.org.springframework.web.servlet.tags.MessageTag=FATAL
log4j.logger.org.asqatasun.crawler=INFO
log4j.logger.org.asqatasun.service=INFO
log4j.logger.org.asqatasun.contentadapter=INFO
log4j.logger.org.asqatasun.webapp.validator=INFO
log4j.logger.org.asqatasun.contentadapter.css=INFO
log4j.logger.org.asqatasun.webapp.presentation.factory.TestResultFactory=ERROR
log4j.logger.org.asqatasun.webapp.orchestrator=INFO
log4j.logger.org.springframework.web.servlet.DispatcherServlet=INFO
log4j.logger.org.asqatasun.scenarioloader=INFO
log4j.logger.org.jsoup=INFO
log4j.logger.org.asqatasun.contentadapter.css=ERROR
log4j.logger.com.sebuilder=INFO
log4j.logger.com.phloc.css.parser=FATAL
log4j.logger.org.asqatasun.webapp = DEBUG 

I tested your log4j.properties file and it works:

DEBUG org.springframework.security.web.access.ExceptionTranslationFilter  - Chain processed normally
DEBUG org.springframework.security.web.context.SecurityContextPersistenceFilter  - SecurityContextHolder now cleared, as request processing completed
DEBUG org.springframework.security.web.session.HttpSessionEventPublisher  - Publishing event: org.springframework.security.web.session.HttpSessionDestroyedEvent[source=org.apache.catalina.session.StandardSessionFacade@55c6b659]

Is this the content of var/lib/asqatasun.log?

yes, this is the content of var/lib/asqatasun.log in docker.

I use these following command lines:

docker/compile_and_build_docker_image.sh -l -s ${PWD} -d docker/single-container-SNAPSHOT-local  --skip-build-test --use-sudo-docker
sudo docker logs -f  asqa

can you tell us the path off your class where you added something like LOGGER.debug(“message”)?

The path is /Asqatasun/web-app/asqatasun-web-app/src/main/java/org/asqatasun/webapp/controller/

Ok finally worked! Thanks a lot!