What do you mean by additivity flag? I've noticed that replacing the _log.debug with System.out.println() does not result in the same error:
... System.out.println(playerOne); ... Output Player One holds the following cards: THREE of DIAMONDS KING of DIAMONDS whilst... ... _log.debug(playerTwo + "."); ... Output 172 [main] DEBUG poker.Poker - Player Two holds the following cards: TEN of DIAMONDS SEVEN of SPADES . 172 [main] DEBUG poker.Poker - Player Two holds the following cards: TEN of DIAMONDS SEVEN of SPADES . 172 [main] DEBUG poker.Poker - Player Two holds the following cards: TEN of DIAMONDS SEVEN of SPADES . ... On 24 April 2011 13:22, Christian Grobmeier <[email protected]> wrote: > Hey Jonathan, > > the log4j configuration is more of interest for your case. However, as > you now got output, I assume the logging itself is working. > > Your double entries - for that i am pretty sure - come from the additivity > flag. > > Please go to: http://logging.apache.org/log4j/1.2/manual.html > and search for "Appender Additivity" > > This will help you > > cheers > > > On Sun, Apr 24, 2011 at 1:17 PM, Jonathan Camilleri > <[email protected]> wrote: > > Well thanks for the information about pom.xml, I'm trying to stick with > > log4j.properties, so I'm attaching a copy of my cmd.log - command line > log. > > I've encountered another weird problem when trying to review the output > of > > Apache log 4j on the console, since some how lines are being written > > multiple times, although I suspect this has to do with looping through an > > ArrayList (a java problem), however, I am not sure, because I haven't > > noticed any flaws in my code: > > Code > > package poker; > > import java.awt.Image; > > import java.io.BufferedInputStream; > > import java.io.File; > > import java.io.FileInputStream; > > import java.io.IOException; > > import java.io.InputStream; > > import java.util.*; > > import javax.imageio.ImageIO; > > import org.apache.log4j.BasicConfigurator; > > import org.apache.log4j.Logger; > > public class Poker { > > public static void main(String[] args) { > > BasicConfigurator.configure(); > > ... > > Player playerOne = new Player("Player One"); > > playerOne.getCardFromDealer(getTopCard()); > > playerOne.getCardFromDealer(getTopCard()); > > _log.debug(playerOne + "."); > > _log.debug(playerOne.hashCode()); > > Player playerTwo = new Player("Player Two"); > > playerTwo.getCardFromDealer(getTopCard()); > > playerTwo.getCardFromDealer(getTopCard()); > > _log.debug(playerTwo + "."); > > _log.debug(playerTwo.hashCode()); > > ... > > for (int i = 0; i < deckOfCards.size(); i++) { > > _log.debug(deckOfCards.get(i));} > > } > > private static void getCards (boolean _shuffled) { > > short iCount = 0; > > for (short suit = 1; suit <= MAX_SUITS_IN_DECK; suit++){ > > for (short rank = 1; rank <= MAX_RANK_IN_DECK; rank++) { > > deckOfCards.add(new Card(suit, rank)); > > iCount++; > > }} > > if (_shuffled == true){Collections.shuffle(deckOfCards, new Random());} > > } > > > > private static Card getTopCard() { > > Card _cardRemoved = deckOfCards.get(1); > > deckOfCards.remove(1); > > return _cardRemoved; > > } > > private static void readIcons(){ > > String _filename; > > //read icons > > Image _image = null; > > File _file = null; > > InputStream _is = null; > > for (int i = 1; i < MAX_CARDS_IN_DECK + 1; i++) { > > try { > > /* Security information: filenames should not be altered manually by > an > > Administrator, and, > > should be available within the same directory where the source code > > runs. */ > > if (i < 10) {_filename = "0" + Integer.toString(i);} > > else {_filename = Integer.toString(i);} > > String _temp = _filename; > > _filename = _temp + ".GIF"; > > //TODO: Relative path might change when implementing? > > _filename = System.getProperty("user.dir") + "\\img\\" + _filename; > > _file = new File(_filename); > > //read from an input stream > > _is = new BufferedInputStream (new FileInputStream(_filename)); > > _image = ImageIO.read(_is); > > if (_file.exists()) { > > CardIcons.add(_image); > > _log.debug(_filename + " loaded."); > > } > > } > > catch (IOException e) { _log.debug(e.getMessage()); } > > } > > } > > private static ArrayList<Image> CardIcons = new ArrayList<Image>(); > > private static ArrayList<Card> deckOfCards = new ArrayList<Card>(); > > private static final Logger _log = Logger.getLogger(Poker.class); > > public static final short MAX_CARDS_IN_DECK = 52; > > public static final short MAX_SUITS_IN_DECK = 4; > > public static final short MAX_RANK_IN_DECK = 13; > > public static final short MAX_PLAYERS_PER_TABLE = 5; > > public static final short MAX_GAMES_PER_SESSION = 1; //TODO: implement > > concurrent games and UI at a later stage. > > /* References > > * ---------- > > * Information about poker at http://en.wikipedia.org/wiki/Poker. > > * List of poker hands at http://en.wikipedia.org/wiki/Poker_hands. > > * Rules for Texas Hold'Em at http://en.wikipedia.org/wiki/Texas_hold_'em > . > > This will be implemented at a later stage. > > * Steve Badger, How to Play Poker at > > http://www.playwinningpoker.com/articles/how-to-play-poker. > > * Graphics to be implemented at a later stage. > > */ > > } > > Player.java > > ... > > public String toString() { > > String _cardsHeld = ""; > > BasicConfigurator.configure(); > > //TODO: DEBUG grammatical error i.e. comma separating each card and "." > for > > the last card, the last rule is not working as expected. > > for (int i = 0; i < CardsHeld.size(); i++) {_cardsHeld += > > CardsHeld.get(i).toString() + " ";} > > return (name + " holds the following cards: " + _cardsHeld) ; > > } > > ... > > public int hashCode() { > > int _hash = 7; > > int _cpCount = this.name.codePointCount(0, name.length()); > > int _codePointV = 0; > > while (_cpCount < this.name.length()) { > > _codePointV += this.name.codePointAt(_cpCount); > > _cpCount++; > > } > > _hash = _hash * 31 + _codePointV; > > return _hash; > > } > > > > Output > > [main] DEBUG poker.Poker - Player One holds the following cards: TEN of > > HEARTS SEVEN of CLUBS . > > 172 [main] DEBUG poker.Poker - Player One holds the following cards: TEN > of > > HEARTS SEVEN of CLUBS . > > 172 [main] DEBUG poker.Poker - 217 > > 172 [main] DEBUG poker.Poker - 217 > > 172 [main] DEBUG poker.Poker - Player Two holds the following cards: > SEVEN > > of SPADES TEN of CLUBS . > > 172 [main] DEBUG poker.Poker - Player Two holds the following cards: > SEVEN > > of SPADES TEN of CLUBS . > > 172 [main] DEBUG poker.Poker - Player Two holds the following cards: > SEVEN > > of SPADES TEN of CLUBS . > > 172 [main] DEBUG poker.Poker - 217 > > 172 [main] DEBUG poker.Poker - 217 > > 172 [main] DEBUG poker.Poker - 217 > > Rgds, > > Jonathan > > > > On 24 April 2011 11:05, Christian Grobmeier <[email protected]> wrote: > >> > >> Hello Jonathan, > >> > >> this message appears when the log4j.xml|properties file could not be > >> found on your classpath. > >> Usually it should be at src/main/resources, this folder visible as > >> classpath folder on eclipse. > >> > >> However you can start your app with -Dlog4j.debug=true to spot out at > >> which locations your configuration is searched > >> > >> Your pom.xml is a maven file and should not have any impact on log4j > >> (except you need the dependency of course). Same is true for eclipse. > >> Only th elocation of your config file is important. > >> > >> Cheers > >> > >> On Sat, Apr 23, 2011 at 6:53 PM, Jonathan Camilleri > >> <[email protected]> wrote: > >> > Hi, > >> > Any idea why my logger is not logging (see Deck.java). Error message: > >> > log4j:WARN No appenders could be found for logger (poker.Deck). > >> > log4j:WARN Please initialize the log4j system properly. > >> > log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfigfor > >> > more info. > >> > TWO of CLUBS > >> > Having, googled the issue, I tried adding pom.xml to the directory > where > >> > the > >> > source code files reside. I am using Eclipse 3.6.2, which has an > >> > intricate > >> > way of adding JARs to my project. > >> > Any ideas? > >> > > >> > -- > >> > Jonathan Camilleri > >> > > >> > Mobile (MT): 00356 7982 7113 > >> > E-mail: [email protected] > >> > Please consider your environmental responsibility before printing this > >> > e-mail. > >> > > >> > I usually reply to e-mails within 2 business days. If it's urgent, > give > >> > me > >> > a call. > >> > > >> > > >> > --------------------------------------------------------------------- > >> > To unsubscribe, e-mail: [email protected] > >> > For additional commands, e-mail: [email protected] > >> > > >> > >> > >> > >> -- > >> http://www.grobmeier.de > > > > > > > > -- > > Jonathan Camilleri > > > > Mobile (MT): 00356 7982 7113 > > E-mail: [email protected] > > Please consider your environmental responsibility before printing this > > e-mail. > > > > I usually reply to e-mails within 2 business days. If it's urgent, give > me > > a call. > > > > > > -- > http://www.grobmeier.de > -- Jonathan Camilleri Mobile (MT): 00356 7982 7113 E-mail: [email protected] Please consider your environmental responsibility before printing this e-mail. I usually reply to e-mails within 2 business days. If it's urgent, give me a call.
0 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\01.GIF loaded. 15 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\02.GIF loaded. 15 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\03.GIF loaded. 15 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\04.GIF loaded. 15 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\05.GIF loaded. 31 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\06.GIF loaded. 31 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\07.GIF loaded. 31 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\08.GIF loaded. 31 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\09.GIF loaded. 31 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\10.GIF loaded. 47 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\11.GIF loaded. 47 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\12.GIF loaded. 47 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\13.GIF loaded. 47 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\14.GIF loaded. 47 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\15.GIF loaded. 62 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\16.GIF loaded. 62 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\17.GIF loaded. 62 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\18.GIF loaded. 62 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\19.GIF loaded. 62 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\20.GIF loaded. 62 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\21.GIF loaded. 78 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\22.GIF loaded. 78 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\23.GIF loaded. 78 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\24.GIF loaded. 78 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\25.GIF loaded. 94 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\26.GIF loaded. 94 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\27.GIF loaded. 94 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\28.GIF loaded. 94 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\29.GIF loaded. 94 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\30.GIF loaded. 94 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\31.GIF loaded. 109 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\32.GIF loaded. 109 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\33.GIF loaded. 109 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\34.GIF loaded. 109 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\35.GIF loaded. 109 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\36.GIF loaded. 125 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\37.GIF loaded. 125 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\38.GIF loaded. 125 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\39.GIF loaded. 125 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\40.GIF loaded. 125 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\41.GIF loaded. 140 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\42.GIF loaded. 140 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\43.GIF loaded. 140 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\44.GIF loaded. 140 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\45.GIF loaded. 156 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\46.GIF loaded. 156 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\47.GIF loaded. 156 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\48.GIF loaded. 156 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\49.GIF loaded. 156 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\50.GIF loaded. 156 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\51.GIF loaded. 172 [main] DEBUG poker.Poker - C:\Documents and Settings\Jon\workspace\Poker\img\52.GIF loaded. Player One holds the following cards: THREE of DIAMONDS KING of DIAMONDS 217 172 [main] DEBUG poker.Poker - Player Two holds the following cards: TEN of DIAMONDS SEVEN of SPADES . 172 [main] DEBUG poker.Poker - Player Two holds the following cards: TEN of DIAMONDS SEVEN of SPADES . 172 [main] DEBUG poker.Poker - Player Two holds the following cards: TEN of DIAMONDS SEVEN of SPADES . 172 [main] DEBUG poker.Poker - 217 172 [main] DEBUG poker.Poker - 217 172 [main] DEBUG poker.Poker - 217 Player Three holds the following cards: NINE of HEARTS ACE of CLUBS . Player Four holds the following cards: JACK of DIAMONDS TWO of SPADES . Player Five holds the following cards: QUEEN of CLUBS TEN of HEARTS . FOUR of DIAMONDS EIGHT of SPADES QUEEN of DIAMONDS THREE of SPADES JACK of SPADES TWO of CLUBS THREE of CLUBS FOUR of SPADES ACE of HEARTS TWO of HEARTS TEN of CLUBS EIGHT of HEARTS SIX of DIAMONDS EIGHT of DIAMONDS KING of CLUBS QUEEN of HEARTS JACK of CLUBS ACE of DIAMONDS SIX of SPADES FIVE of DIAMONDS ACE of SPADES SEVEN of HEARTS SEVEN of CLUBS THREE of HEARTS SIX of HEARTS QUEEN of SPADES NINE of DIAMONDS TWO of DIAMONDS EIGHT of CLUBS FIVE of HEARTS SEVEN of DIAMONDS SIX of CLUBS KING of HEARTS FIVE of SPADES FOUR of HEARTS NINE of SPADES NINE of CLUBS TEN of SPADES FIVE of CLUBS FOUR of CLUBS KING of SPADES JACK of HEARTS
Poker.java
Description: Binary data
Player.java
Description: Binary data
Card.java
Description: Binary data
log4j.properties
Description: Binary data
--------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
