Property Files

Now, we will create two property files to src/main/resources/ , right-click to create a new file called log4j.properties with below settings. After running the app, you can find the log file (SpringMVCExample.log) under C:\logs\ folder.

# logger option for File and stdout

log4j.rootLogger=INFO, File, stdout

# Logging levels : ALL, DEBUG, INFO, WARN, ERROR, FATAL, OFF

# Output log messages to stdout – console

log4j.appender.stdout=org.apache.log4j.ConsoleAppender

log4j.appender.stdout.Target=System.out

log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %c{1} – %m%n

# Output log messages to a log file

log4j.appender.File=org.apache.log4j.RollingFileAppender

log4j.appender.File.File=C:\\logs\\SpringMVCExample.log

log4j.appender.File.MaxFileSize=10MB

log4j.appender.File.MaxBackupIndex=10

log4j.appender.File.layout=org.apache.log4j.PatternLayout

log4j.appender.File.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %c{1} – %m%n

# Hibernate logging options

log4j.logger.org.hibernate=INFO

# showing hibernate SQL with parameter values

log4j.logger.org.hibernate.type=trace

 

Then, right-click to create a new file called messages_en.properties with below value pair, it is using to support multiple languages for your application.

message.welcome=Welcome !!!

form.create=Create Form

form.update=Update Form

form.label.id=ID

form.label.name=Name

form.label.telephone=Telephone

form.label.fax=Fax

form.label.email=Email

form.label.status=Status

form.label.address=Address

form.label.address.country=Country

form.label.address.city=City

form.label.address.street=Street

form.label.address.building=Building

form.label.firstname=Firstname

form.label.lastname=Lastname

form.label.age=Age

form.label.gender=Gender

form.label.orderDate=Order Date

form.label.price=Price

form.label.customer=Customer

form.label.details=Details

form.label.products=Products

NotEmpty=Compulsory Field

NotNull=Compulsory Field

Min.customer.age=Age must be > 0

Max.customer.age=Age must be <= 150

typeMismatch.java.lang.Integer=Please fill in integer

typeMismatch.java.lang.Double=Please fill in valid number

typeMismatch.java.util.Date=Please fill in valid Date yyyy-MM-dd hh:mm:ss

 

Create another file called messages_fr.properties with:

message.welcome=Bienvenue !!!

 

form.create=Créer un formulaire

form.update=Mise à jour le formulaire

form.label.id=ID

form.label.name=prénom

form.label.telephone=Téléphone

form.label.fax=Fax

form.label.email=Email

form.label.status=statut

form.label.address=Adresse

form.label.address.country=Pays

form.label.address.city=Ville

form.label.address.street=rue

form.label.address.building=Bâtiment

form.label.firstname=Prénom

form.label.lastname=Nom

form.label.age=Age

form.label.gender=Sexe

form.label.orderDate=Date de commande

form.label.price=Prix

form.label.customer=client

form.label.details=Détails

form.label.products=Produit

NotEmpty=imposée

NotNull=imposée

Min.customer.age=âge doit être> 0

Max.customer.age=âge doit être <= 150

 

typeMismatch.java.lang.Integer=S’il vous plaît remplir entier

typeMismatch.java.lang.Double=S’il vous plaît remplir numéro valide

typeMismatch.java.util.Date=S’il vous plaît remplir hh DATE AAAA-MM-JJ valides: mm: ss

 

And the last file called messages_zh.properties with:

message.welcome=歡迎 !!!

 

form.create=創建表單

form.update=更新表單

form.label.id=ID

form.label.name=名稱

form.label.telephone=電話

form.label.fax=傳真

form.label.email=電郵

form.label.status=狀態

form.label.address=地址

form.label.address.country=國家

form.label.address.city=城

form.label.address.street=街

form.label.address.building=大廈

form.label.firstname=名字

form.label.lastname=姓氏

form.label.age=年齡

form.label.gender=性別

form.label.orderDate=訂單日期

form.label.price=價格

form.label.customer=客戶

form.label.details=詳細

form.label.products=產品

NotEmpty=必須

NotNull=必須

Min.customer.age=年齡必須>0

Max.customer.age=年齡必須<=150

typeMismatch.java.lang.Integer=請填寫整數

typeMismatch.java.lang.Double=請填寫有效的數字

typeMismatch.java.util.Date=請填寫有效日期 yyyy-MM-dd hh:mm:ss

Please rate this