27
27
import org .codehaus .cargo .container .configuration .ConfigurationType ;
28
28
import org .codehaus .cargo .container .configuration .LocalConfiguration ;
29
29
import org .codehaus .cargo .container .deployable .WAR ;
30
+ import org .codehaus .cargo .container .jetty .JettyPropertySet ;
30
31
import org .codehaus .cargo .container .property .GeneralPropertySet ;
31
32
import org .codehaus .cargo .container .property .LoggingLevel ;
32
33
import org .codehaus .cargo .container .property .ServletPropertySet ;
47
48
* Subclasses provide setup and configuration of specific containers.
48
49
*/
49
50
public abstract class ServerContainer {
51
+ private final File containerConfigHome ;
50
52
private InstalledLocalContainer container ;
51
53
private ContainerInstall install ;
52
54
@@ -66,7 +68,7 @@ public abstract class ServerContainer {
66
68
67
69
public final String DEFAULT_CONF_DIR ;
68
70
69
- public static final String DEFAULT_LOGGING_LEVEL = LoggingLevel .HIGH .getLevel ();
71
+ public static final String DEFAULT_LOGGING_LEVEL = LoggingLevel .LOW .getLevel ();
70
72
public static final String DEFAULT_LOG_DIR = "cargo_logs/" ;
71
73
public static final String DEFAULT_CONFIG_DIR = "/tmp/cargo_configs/" ;
72
74
@@ -99,8 +101,8 @@ public ServerContainer(ContainerInstall install, File containerConfigHome,
99
101
100
102
DEFAULT_CONF_DIR = install .getHome () + "/conf/" ;
101
103
// Use the default configuration home path if not passed a config home
102
- if ( containerConfigHome == null )
103
- containerConfigHome = new File (DEFAULT_CONFIG_DIR + description );
104
+ this . containerConfigHome = containerConfigHome == null
105
+ ? new File (DEFAULT_CONFIG_DIR + description ) : containerConfigHome ;
104
106
105
107
// Init the property lists
106
108
cacheProperties = new HashMap <>();
@@ -111,7 +113,7 @@ public ServerContainer(ContainerInstall install, File containerConfigHome,
111
113
// Create the Cargo Container instance wrapping our physical container
112
114
LocalConfiguration configuration = (LocalConfiguration ) new DefaultConfigurationFactory ()
113
115
.createConfiguration (install .getInstallId (), ContainerType .INSTALLED ,
114
- ConfigurationType .STANDALONE , containerConfigHome .getAbsolutePath ());
116
+ ConfigurationType .STANDALONE , this . containerConfigHome .getAbsolutePath ());
115
117
// Set configuration/container logging level
116
118
configuration .setProperty (GeneralPropertySet .LOGGING , loggingLevel );
117
119
// Removes secureRandom generation so that container startup is much faster
@@ -210,6 +212,25 @@ public void stop() {
210
212
container .stop ();
211
213
}
212
214
215
+ public void dumpLogs () throws IOException {
216
+ for (File file : logDir .listFiles ()) {
217
+ dumpToStdOut (file );
218
+ }
219
+
220
+ for (File file : new File (containerConfigHome , "logs" ).listFiles ()) {
221
+ dumpToStdOut (file );
222
+ }
223
+ }
224
+
225
+ private void dumpToStdOut (final File file ) throws IOException {
226
+ System .out .println ("-------------------------------------------" );
227
+ System .out .println (file .getAbsolutePath ());
228
+ System .out .println ("-------------------------------------------" );
229
+ FileUtils .copyFile (file , System .out );
230
+ System .out .println ("-------------------------------------------" );
231
+ System .out .println ("" );
232
+ }
233
+
213
234
/**
214
235
* Copies the container configuration (found through {@link #getConfiguration()}) to the logging
215
236
* directory specified by {@link #logDir}
0 commit comments