Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging is configured to use root folders #73

Open
guruprasads7 opened this issue Jul 9, 2018 · 7 comments
Open

Logging is configured to use root folders #73

guruprasads7 opened this issue Jul 9, 2018 · 7 comments

Comments

@guruprasads7
Copy link
Collaborator

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.

<logback.dir>/logs/</logback.dir>
<logback.archive>/logs/archived/</logback.archive>

                     <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
Copy link
Contributor

KHaack commented Jul 9, 2018

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

@KHaack KHaack assigned sepidetari and unassigned AndreSonntag Jul 9, 2018
@sepidetari
Copy link
Collaborator

sepidetari commented Jul 9, 2018

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
Copy link
Collaborator Author

@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
Copy link
Collaborator

sepidetari commented Jul 9, 2018

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
Copy link
Collaborator Author

guruprasads7 commented Jul 9, 2018

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
Copy link
Contributor

KHaack commented Jul 10, 2018

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
Copy link
Collaborator Author

In this way, anyhow you won't be running logstash docker container. This is also evaluated in windows environment ${project.basedir} <logback.dir>${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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants