dice-group / sask

Projectgroups Search and Extraction
GNU Affero General Public License v3.0
2 stars 10 forks source link

Logging is configured to use root folders #73

Open guruprasads7 opened 6 years ago

guruprasads7 commented 6 years ago

Currently, the logging directory specified in logback-spring.xml are restricted directories which the application might not have access to in this case, it fails with a fileNotFound caused due to insufficient permissions. Ideally these log files should be in the scope of the sask application. Hence its desirable to be in a configurable directory, rather than hard coding them.

/logs/ /logs/archived/
                     <properties>
            <logback.dir>C:/logs/</logback.dir>
            <logback.archive>C:/logs/archived/</logback.archive>
        </properties>

One of the suggested option is to have these logs in the parent sask folder like or have an enviroment variable providing even more flexibilty

                    <properties>
            <logback.dir>${project.basedir}/logs/</logback.dir>
            <logback.archive>${project.basedir}/logs/archived/</logback.archive>
        </properties>

By doing so, we can get away from linux and windows profiles.

Let me know your thoughts on the same.

KHaack commented 6 years ago

we need one central directory for logstash. And we need a absolute path for this. So it has to be configured somewhere anyway

sepidetari commented 6 years ago

As @KHaack mentioned, logstash is running in docker and its config file just works by absolute path so one folder, shared by docker and host machine, is needed to store all logs inside. link to logstash docs

guruprasads7 commented 6 years ago

@KHaack @sepidetari, Since logstash is running as a docker container, the volume you mount inside the docker container is configurable, for example

Taken from the wiki page sudo docker run -h docker.elastic.co/logstash/logstash:6.0.1 -p 5044:5044 --name logstash --link elasticsearch:elasticsearch -v /usr/share/logstash/pipeline/:/usr/share/logstash/pipeline/ -v /logs/:/logs docker.elastic.co/logstash/logstash:6.0.1 -f /usr/share/logstash/pipeline/logstash.conf

As you are aware this basically tells it find where the log files for parsing is... -v /logs/:/logs in this case you can mount any host directory something like this -v /anyhostdirectory/logs:/logs, even then your logstash will work.

The problem with hardcoding /logs , it definitely fails on MacOSX. I could fix it, but not everyone would look into the code.

sepidetari commented 6 years ago

If I understoond you correctly, there is no difference between "-v /anyhostdirectory/logs:/logs" and /logs:/logs and in both case the path should be hard coded in logstash-spring.xml folder.( /logs or /anyhostdirectory/logs folder)

guruprasads7 commented 6 years ago

Your logstash config file reads the input

input { file { path => "/logs/*.log" type => logs
} }

You are right for a fact that logstash needs absolute path *"/logs/.log" . But when you mount directory in to docker container using -v /logs/:/logs**, basically what you are doing is mounting the host directory /logs into docker container directory /logs. Hence your logstash config is able to parse the log files.

Instead if you do something like this -v /anyhostdirectory/logs:/logs, incase as well, you are mounting the log files from the host /anyhostdirectory/log to the logstash docker container on /logs/ in this case aswell the logstash container sees the files in /logs folder. For the logstash container, it doesn't matter which host directory is mounted to /logs inside container.

KHaack commented 6 years ago

jep, but what if you run your project in a local setup without docker on a windows machine?

i think there is no way around that

guruprasads7 commented 6 years ago

In this way, anyhow you won't be running logstash docker container. This is also evaluated in windows environment ${project.basedir} ${project.basedir}/logs/</logback.dir>. Which would create logs on the directory where the project is run. We can use the same value for both windows and linux machines.

And in the linux machine, we can modify the logstash config to input { file { path => "/projecthomedirectory/*/.log" type => logs } }

In this way the logstash can check inside recursive directories like eureka-server, chatbot.. etc. And when we deploy these as docker containers, we would have component wise logs as well.