question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ensure all properties map nicely to yaml

See original GitHub issue
logging.file=logs/app.log
logging.file.max-history=20 
logging.file.max-size=50MB 

how to config these properties in yml file

#log 
logging:
  file:  // how to config
    max-history: 30
    max-size: 50MB

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:17 (10 by maintainers)

github_iconTop GitHub Comments

34reactions
philwebbcommented, Mar 16, 2018

I think I finally understand the issue here. A sample would have been very useful. As would have including the full stack trace.

Given the following YAML:

logging:
  file: logs/app.log
    max-history: 20
    max-size: 50MB

The following exception is raised:

java.lang.IllegalStateException: Failed to load property source from location 'classpath:/application.yml'
	at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:481)
	at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.loadForFileExtension(ConfigFileApplicationListener.java:446)
	at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:419)
	at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:329)
	at org.springframework.boot.context.config.ConfigFileApplicationListener.addPropertySources(ConfigFileApplicationListener.java:205)
	at org.springframework.boot.context.config.ConfigFileApplicationListener.postProcessEnvironment(ConfigFileApplicationListener.java:188)
	at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:175)
	at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:161)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
	at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74)
	at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
	at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:351)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:317)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1234)
	at scratch.BindingApplication.main(BindingApplication.java:10)
Caused by: org.yaml.snakeyaml.scanner.ScannerException: mapping values are not allowed here
 in 'reader', line 3, column 16:
        max-history: 20
                   ^

	at org.yaml.snakeyaml.scanner.ScannerImpl.fetchValue(ScannerImpl.java:872)
	at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:360)
	at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:226)
	at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockMappingKey.produce(ParserImpl.java:557)
	at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:157)
	at org.yaml.snakeyaml.parser.ParserImpl.checkEvent(ParserImpl.java:147)
	at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:227)
	at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:154)
	at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:249)
	at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:240)
	at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:228)
	at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:154)
	at org.yaml.snakeyaml.composer.Composer.composeDocument(Composer.java:122)
	at org.yaml.snakeyaml.composer.Composer.getNode(Composer.java:84)
	at org.yaml.snakeyaml.constructor.BaseConstructor.getData(BaseConstructor.java:123)
	at org.yaml.snakeyaml.Yaml$1.next(Yaml.java:547)
	at org.springframework.beans.factory.config.YamlProcessor.process(YamlProcessor.java:161)
	at org.springframework.beans.factory.config.YamlProcessor.process(YamlProcessor.java:139)
	at org.springframework.boot.env.OriginTrackedYamlLoader.load(OriginTrackedYamlLoader.java:75)
	at org.springframework.boot.env.YamlPropertySourceLoader.load(YamlPropertySourceLoader.java:49)
	at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:469)
	... 18 common frames omitted

You can work around it by doing this:

logging.file: logs/app.log 
logging:
  file: 
    max-history: 20
    max-size: 50MB
2reactions
mbhavecommented, Apr 19, 2019

I couldn’t find any other properties that can’t be mapped in YAML. spring.profiles when combined with spring.profiles.include/active seems to be the only one and I don’t think we should do anything about that till we decide how we want to handle include profiles in profile-specific YAML documents.

I’m in favor of closing this issue now that logging.file has been renamed to logging.file.name.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is the correct use of the property map read from .yaml ...
What is the correct use of the property map read from .yaml with @Value Spring Annotation ; @Value("#{${app.map}}") private Map<String, String> ...
Read more >
Inject a Map from a YAML File with Spring - Baeldung
Learn how to inject a Map from a YAML file in Spring Boot. ... Then we'll demonstrate how to bind YAML properties to...
Read more >
24. Externalized Configuration - Spring
You can use properties files, YAML files, environment variables, and command-line arguments to externalize configuration.
Read more >
Tips, Tricks, Troubleshooting - yq - GitBook
Yaml files can be surprisingly lenient in what can be parsed as a yaml file. A reasonable way of validation a yaml file...
Read more >
10 YAML tips for people who hate YAML | Enable Sysadmin
Computers tend to do well with predictability, so the concept of a linter ... You might be stuck with YAML because that's the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found