First, in the config. Groovy File
Open
Import org. Apache. log4j. dailyrollingfileappender
Import org. springframework. Core. Io. classpathresource
Import org. springframework. Core. Io. Support. propertiesloaderutils
Import org. springframework. Core. Io. Resource
Def config;
Try {
Resource res = new classpathresource ("uts-config.properties ");
Config = new properties ();
Config. Load (New inputstreamreader (res. getinputstream (), "UTF-8 "));
} Catch (exception e ){
E. printstacktrace ()
Fileinputstream file = new fileinputstream ("grails-APP/CONF/uts-config.properties ");
Config = new properties ();
Config. Load (New inputstreamreader (file, "UTF-8 "));
File. Close ();
}
Def log4jlevel = config ["log4j. Level"];
Grails. Mime. file. Extensions = true // enables the parsing of file extensions from URLs into the request format
Grails. Mime. Use. Accept. header = false
Grails. Mime. types = [HTML: ['text/html', 'application/XHTML + xml'],
XML: ['text/xml', 'application/xml'],
Text: 'text/plain ',
JS: 'text/JavaScript ',
RSS: 'application/RSS + xml ',
Atom: 'application/atom + xml ',
CSS: 'text/CSS ',
CSV: 'text/csv ',
ALL :'*/*',
JSON: ['application/json', 'text/json'],
Form: 'application/X-WWW-form-urlencoded ',
Multipartform: 'multipart/form-data'
]
Grails. Views. Default. codec = "NONE" // none, HTML, base64
Grails. Views. GSP. Encoding = "UTF-8"
Grails. converters. Encoding = "UTF-8"
// Enabled native2ascii conversion of i18n properties files
Grails. Enable. native2ascii = true
// Set per-Environment serverurl stem for creating absolute links
Environments {
Production {
Grails. GSP. Enable. reload = true
Def classpaths = "$ {appname}/WEB-INF/grails-app ";
Grails. Reload. Location = classpaths
System. setproperty ("basdire.", classpaths)
Grails. serverurl = "http://www.changeme.com"
}
Development {
Grails. serverurl = "http: // localhost: 8080/$ {appname }"
}
Test {
Grails. serverurl = "http: // localhost: 8080/$ {appname }"
}
}
// Log4j Configuration
Log4j = {
Appenders {
Console name: 'console', layout: pattern (conversionpattern: '% d {yyyy-mm-dd hh: mm: SS} [% P] % c {2} % m % n ')
Appender new dailyrollingfileappender (name: "dailyrollingfile", datepattern :"'. 'yyyymmdd ", file:" log/UTs. daily. log ", layout: pattern (conversionpattern: '% d {yyyy-mm-dd hh: mm: SS} [% P] % c {2} % m % n '))
// File name: 'file', file: 'Log/UTs. Log'
// Rollingfile name: "rollingfile", maxfilesize: 4*1024*1024, file: "log/UTs. rolling. log ", layout: pattern (conversionpattern: '% d {yyyy-mm-dd hh: mm: SS} [% P] % c {2} % m % n ')
}
Root {
Error 'console', 'dailyrollingfile'
Additivity = true
}
// Todo: Read log4j. Level from uts-config.properties
"$ {Log4jlevel}" dailyrollingfile: "grails. App. Controller", "grails. App. Domain", "grails. App. Service", "com. itrus"
// Error 'org. codehaus. Groovy. grails. Web. servlet ', // Controllers
// 'Org. codehaus. Groovy. grails. Web. pages', // GSP
// 'Org. codehaus. Groovy. grails. Web. sitemesh ', // layouts
// 'Org. codehaus. Groovy. grails. Web. Mapping. filter', // URL Mapping
// 'Org. codehaus. Groovy. grails. Web. mapping', // URL Mapping
// 'Org. codehaus. Groovy. grails. commons ', // Core/classloading
// 'Org. codehaus. Groovy. grails. INS ins ', // plugins
// 'Org. codehaus. Groovy. grails. Orm. hibernate ', // hibernate Integration
// 'Org. springframework ',
// 'Org. hibernate'
// Warn 'org. mortbay. Log'
}
Mainly in environments {
Add the following part
Production {
Grails. GSP. Enable. reload = true
Def classpaths = "$ {appname}/WEB-INF/grails-app ";
Grails. Reload. Location = classpaths
System. setproperty ("basdire.", classpaths)
Grails. serverurl = "http://www.changeme.com"
}
}
After saving the package, directly compress it into a war package.