}
private void doUpgrade(Config config) {
// v3 uses logging.properties to configure the logging facility.
// move all log-service elements to logging.properties
final LogService logService = config.getLogService();
// check if null and exit
if (logService == null )
return;
// get a copy of the logging.properties file
try {
RepositoryConfig rc = new RepositoryConfig();
String configDir = rc.getRepositoryRoot()+ File.separator +rc.getRepositoryName() +
File.separator+ rc.getInstanceName() +File.separator + "config";
PEFileLayout layout = new PEFileLayout(rc);
File src = new File(layout.getTemplatesDir(), PEFileLayout.LOGGING_PROPERTIES_FILE);
File dest = new File (configDir, PEFileLayout.LOGGING_PROPERTIES_FILE);
if (!dest.exists())
FileUtils.copy(src, dest);
} catch (IOException ioe) {
Logger.getAnonymousLogger().log(Level.SEVERE, "Failure while upgrading log-service. Could not create logging.properties file. ", ioe);
}
try {
//Get the logLevels
ModuleLogLevels mll = logService.getModuleLogLevels();
Map<String, String> logLevels = mll.getAllLogLevels();
String file=logService.getFile();
String instanceRoot = System.getProperty("com.sun.aas.instanceRoot");
if (file.contains(instanceRoot)){
file = file.replace(instanceRoot ,"${com.sun.aas.instanceRoot}");
}
logLevels.put("file", file);
logLevels.put("use-system-logging", logService.getUseSystemLogging());
//this can have multiple values so need to add
logLevels.put("log-handler", logService.getLogHandler());
logLevels.put("log-filter", logService.getLogFilter());
logLevels.put("log-to-console",logService.getLogToConsole());
logLevels.put("log-rotation-limit-in-bytes",logService.getLogRotationLimitInBytes());
logLevels.put("log-rotation-timelimit-in-minutes", logService.getLogRotationTimelimitInMinutes());
logLevels.put("alarms", logService.getAlarms());
logLevels.put("retain-error-statistics-for-hours", logService.getRetainErrorStatisticsForHours());
final Map<String, String> m = new HashMap<String,String>(logLevels);
ConfigSupport.apply(new SingleConfigCode<Config>() {
public Object run(Config c) throws PropertyVetoException, TransactionFailure {