Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0f548ef

Browse files
Part 25: Add LoggingProperties.java in myfirst-logging-spring-boot-starter module
1 parent 2e60dd2 commit 0f548ef

File tree

1 file changed

+27
-0
lines changed
  • Spring_part_25/myfirst-logging-spring-boot-starter/src/main/java/spring/oldboy/logging/config

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package spring.oldboy.logging.config;
2+
3+
import jakarta.annotation.PostConstruct;
4+
import lombok.Data;
5+
import lombok.NoArgsConstructor;
6+
import lombok.extern.slf4j.Slf4j;
7+
import org.springframework.boot.context.properties.ConfigurationProperties;
8+
9+
@Slf4j
10+
@Data
11+
@NoArgsConstructor
12+
/* Помечаем наш конфигурационный файл и задаем префикс для properties.yaml */
13+
@ConfigurationProperties(prefix = "app.myfirst.logging")
14+
public class LoggingProperties {
15+
/* Добавляем демонстрационные свойства: логирование разрешено/нет и позволим задавать уровень логирования */
16+
/**
17+
* to enable myfirst-starter logging aop on service layer
18+
*/
19+
private boolean enabled;
20+
private String level;
21+
22+
/* Для того чтобы увидеть, что наши свойства проинициализировались с нужными значениями создадим метод */
23+
@PostConstruct
24+
void init() {
25+
log.info("Logging properties initialized: {}", this);
26+
}
27+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /