spring-cloud / spring-cloud-commons

Common classes used in different Spring Cloud implementations
Apache License 2.0
707 stars 704 forks source link

LOG_FILE_IS_UNDEFINED log file is being created on application startup #200

Closed pksinghus closed 7 years ago

pksinghus commented 7 years ago

Adding a dependency on spring-cloud-context in a spring boot project results in an additional log file being generated with the name "LOG_FILE_IS_UNDEFINED".

Spring boot version is 1.5.2.RELEASE, spring cloud context version is 1.2.0.RELEASE

Remove the following dependency and the unnecessary log file is no longer generated on application startup -

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-context</artifactId>
    <version>1.2.0.RELEASE</version>
</dependency>

Sample project is attached - app.zip

spencergibb commented 7 years ago

You should use the release train to reference spring-cloud projects. See start.spring.io for examples.

cooniur commented 7 years ago

Having the same issue here. I provided more details in this ticket: https://github.com/spring-cloud/spring-cloud-commons/issues/219

Feel free to close one of them.

cooniur commented 7 years ago

This bug makes Spring Cloud completely unusable to an application which uses custom Logback configs with variables, because our runtime doesn't give Tomcat user permission to write into the directory.

spencergibb commented 7 years ago

@pksinghus if I change your pom to use the bom

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Dalston.SR1</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

and then remove the version and use the starter for spring-cloud-context

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-logging</artifactId>
        </dependency>

and put logging.file=app.log in bootstrap.properties

I don't get LOG_FILE_IS_UNDEFINED anymore.

cooniur commented 7 years ago

@spencergibb Yes, that solves the issue. And an even better thing is that active profiles will be passed to Spring Cloud bootstrap context, which enables profile-specific bootstrap settings.

In my case, logging location needs to be different between cloud and local environments. I just need to create two bootstrap files, one for cloud bootstrap-cloud.yml:

##
# Spring Cloud Bootstrap settings for running in AWS cloud environment
##
logging.file: "/logs/tomcat/springcloud-bootstrap.log"

and the other for local bootstrap-local.yml

##
# Spring Cloud Bootstrap settings for running in local environment
##
logging.file: "/tmp/springcloud-bootstrap.log"

And Spring Cloud bootstrap context will create logging files accordingly.

No LOG_FILE_IS_UNDEFINED anymore!

But I still hope to see this bug can be resolved by loading application.{properties, yml}, and then put bootstrap.{properties, yml} to the first to override settings in application.{properties, yml}.

spencergibb commented 7 years ago

I'm going to close this as the right dependency configuration is important.